Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try
Sub sheetlocation() MsgBox ActiveSheet.Index End Sub -- Don Guillett SalesAid Software "XP" wrote in message ... 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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just a heads up that this will work if all the sheets to the left are
worksheets. If you insert a chart sheet as the first sheet, for example, it will give you the wrong number. Probably not a problem in your example, but something you should be aware of. -- Regards, Tom Ogilvy "Don Guillett" wrote in message ... try Sub sheetlocation() MsgBox ActiveSheet.Index End Sub -- Don Guillett SalesAid Software "XP" wrote in message ... 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. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's a function that returns the index
Function CurrentLocation() As Integer CurrentLocation = ActiveWorkbook.ActiveSheet.Index End Function -- 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
function to return position in a list | Excel Worksheet Functions | |||
How to return multiple cells from a data sheet in a seperate workbook | Excel Worksheet Functions | |||
Return position for each matching value in entire workbook? | Excel Worksheet Functions | |||
Formula to return cell position | Excel Worksheet Functions | |||
Return Sheet Names from Closed Workbook | Excel Programming |