Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find out how many tabs in the excel file using VBA

Status
Not open for further replies.

veboit

Programmer
Mar 15, 2006
8
0
0
US
I am reading a Excel file using VBA code. I want to find out how many tab(sheets) in that file. then read particular cell in all tab. how can I programmatically find how many tab in that sheet?
thanks your help.
 
Do you mean something like:
Code:
Sub OpenExcel()
'References Microsoft Excel Object Library
Dim exlApp As New Excel.Application
Dim exlWks As Excel.Workbook
    exlApp.Visible = True
    Set exlWks = exlApp.Workbooks.Open _
        ("C:\Docs\Tek-tips.xls")
    Debug.Print exlWks.Worksheets.Count
    exlApp.Quit ' close the application
    Set exlWks = Nothing
    Set exlApp = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top