Sorry if this is a simple question, but I have a For Next loop to swap from the currently activated Workbook to a sheet in a separate workbook based on an Input Box and then re-activating the first workbook. The code worked fine when I opened the originally activated workbook first then the second workbook, but if it is opened inversely the macro does not work. I can successfully get through the InputBox but then it runs into a 'Select method of Worksheet class failed' error. Is the Input Box worksheet selection not working?
Sub Test()
Dim IB As String
Dim Wb As Workbook, Wb2 As Workbook
Set Wb = ActiveWorkbook
For Each Wb2 In Application.Workbooks
Wb2.Activate
Next
IB = InputBox("Enter Month number", "Worksheet selection")
Workbooks("2021 Shipments.xlsx").Worksheets(IB).Select
Wb.Activate
End Sub