I am trying to build a macro to run through a file and open a userform for every sheet that has the name "File-n" where n is an integer. I've tried this code, but it doesn't work:
Dim WS As Worksheet
Dim indx As Integer
For Each WS In ThisWorkbook.Worksheets
WS.Activate
If WS.Name = "File-" & indx Then
WS.Select
userform1.show
End If
Next WS
This macro doesn't recognize any sheets. The code below works, but I was hoping to clean it up if possible. I don't like listing out the potential number of sheets up to thirty.
If WS.Name = "File-0" or WS.Name = "File-1" or WS.Name = "File-2" or ... Then