Friday, April 13, 2012

Loop Through Worksheets Using VBA

Sub loopThruSheetNames()


Dim ws As Worksheet
Dim i As Integer
i = 1
MsgBox "Total Sheets in current workbook are " & ThisWorkbook.Worksheets.Count
For Each ws In ThisWorkbook.Sheets
MsgBox "Name of Sheet " & i & " is " & ws.Name
i = i + 1
Next

End Sub

No comments: