index and names of open workbooks

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
 
G

Gary Keramidas

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
 
B

Bob

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top