I have a workbook with multiple sheets in a master roster book which are named based on a roster cycle number.
Each roster cycle will have varying named sheets with a common number to designate the Roster Cycle eg: "322", "R 322", "OT 322 - WE32".
I am looking for a way to search all my sheets with VBA with an input box to find and select all sheets with the common string ("322" in this case).
I've compiled some code to just find the sheets however i am running into a runtime error 13 when the code gets to the Next ws line.
Is there something I am missing?
Public Sub FindSheets()
Dim RosterCycle As String
Dim ws As Worksheet
RosterCycle = Application.InputBox("Enter Roster Cycle")
For Each ws In ActiveWorkbook.Sheets
If ws.Name Like "*" & RosterCycle & "*" Then ws.Select
found = True
Next ws 'Generates RuntimeError 13
End Sub
I believe you have forgotten an
End If, something like: