index and names of open workbooks

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Hi Everyone:

In excel, is there a way I can get the index and name of all open workbooks,
and once I have that information, to get the name and index of worksheets on
each book? I would appreciate a sample code. Thanks for your help.

Bob
 
maybe something like this. they will be displayed in the immediate window
Sub test()
Dim wb As Workbook
Dim ws As Worksheet
For Each wb In Application.Workbooks
Debug.Print wb.Name
For Each ws In wb.Worksheets
Debug.Print ws.Name, ws.Index
Next
Next
End Sub
 
Thank you Garry. That is what I was looking for. By the way, is there a
way of getting the index of the workbooks.

Bob
 
Back
Top