retrieving sheet names

  • Thread starter Thread starter john
  • Start date Start date
J

john

Is it possible to open a xls application and retrieve all
of the sheet names contained in it? I tried:

sheetName = objActiveWorkbook.Worksheets(1)

but that does not work. Do I need to access a particular
property?
 
Hi John,

We can try:

Dim WS_Count As Integer
Dim I As Integer

' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count

' Begin the loop.
For I = 1 To WS_Count

' Insert your code here.
' The following line shows how to reference a sheet within
' the loop by displaying the worksheet name in a dialog box.
MsgBox ActiveWorkbook.Worksheets(I).Name

Next I

You can refer to the article for more.

Macro to Loop Through All Worksheets in a Workbook
http://support.microsoft.com/?id=142126


Sincerely,

Alick Ye, MCSD
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.




--------------------
| Content-Class: urn:content-classes:message
| From: "john" <[email protected]>
|
| Is it possible to open a xls application and retrieve all
| of the sheet names contained in it? I tried:
|
| sheetName = objActiveWorkbook.Worksheets(1)
|
| but that does not work. Do I need to access a particular
| property?
|
|
 
Back
Top