2012. 8. 11.

How to get list sheetlist from excel file.


' It's not difficult but useful.  Especially when there are many sheets in a excel file.


Sub GetAllList()

Dim all As Sheets

Set all = Application.ActiveWorkbook.Sheets

countOfSheets = all.Count   ' count of sheet

For i = 1 To countOfSheets
    ' sheet1 must be added already. 
    ' insert sheet name into row
    Application.Sheets.Item("Sheet1").Cells(i, 1) = all.Item(i).Name
Next i

End Sub