Excel Help - Sheet ...
 

Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop

[Closed] Excel Help - Sheet Indexes

4 Posts
3 Users
0 Reactions
64 Views
 Haze
Posts: 5413
Free Member
Topic starter
 

Trying to get a specific cell on each worksheet to display its unique index number (1, 2, 3 etc.)

So far I have “=sheetnum()” in the cell with the module...

Function SheetNum() As Integer
SheetNum = ActiveSheet.Index
End Function

This always shows the index number of the last active sheet, so assuming that the “activesheet” bit needs to change – or am I way off/over-thinking things?


 
Posted : 03/03/2014 3:57 pm
Posts: 6480
Free Member
 

What have we become eh?

😛


 
Posted : 03/03/2014 3:59 pm
 Haze
Posts: 5413
Free Member
Topic starter
 

Slow day!!


 
Posted : 03/03/2014 4:07 pm
Posts: 13594
Free Member
 

You need to pass it a cell or range from the WS eg:

Public Function SheetIndex(ByRef Cells As Range) As Integer

SheetIndex = Cells.Worksheet.index

End Function

Called by =sheetindex(E32) in a cell

The E32 is irrelevant, just use any cell in that sheet


 
Posted : 03/03/2014 4:10 pm
 Haze
Posts: 5413
Free Member
Topic starter
 

Perfect, thanks 🙂


 
Posted : 04/03/2014 1:02 pm