Return position of a sheet in a workbook
The following code just picks up the name of the current worksheet and its
index number (its position) and displayes a message box displaying that
information:
Sub WhereAmI()
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ActiveWorkbook
Set ws = ActiveSheet
MsgBox "The active sheet name is " & ws.Name & _
" and its position is " & ws.Index
Set wb = Nothing
Set ws = Nothing
End Sub
--
Kevin Backmann
"XP" wrote:
I am using Office 2003 on Windows XP.
I need a function that would return an integer or a long that indicates the
current position of the active sheet, counting the sheets from left to right.
So if you have sheets named: RawData, Reports, Data, and Calcs in a workbook
and "Data" is currently the active sheet, the function should return 3.
Your example code would be most appreciated. Thanks much in advance.
|