Reputation: 5
Is there a way within vba to count the number of worksheets present in a workbook until a certain worksheet name is reached. For example, the worksheet that I am trying to stop at is called "Summary". I want to know how many sheets are present before that sheet including the "Summary" one.
Upvotes: 0
Views: 846
Reputation: 1
I am new to stack overflow/coding and did not see the undercomplicated response until I finished my way over-complicated version.
Sub CountingSheets()
test1 = Sheets.Count
Count = 0
For I = 1 To test1
If Sheets(I).Name <> Sheets("Summary").Name Then
Count = Count + 1
Else
Exit Sub
End If
Next
End Sub
Upvotes: 0