I am trying to activate a window that I have just opened. My code is as follows:
When it reaches the last line, the error subscript out of range appears. How to fix that?
VBA Code:
Dim quarter As Integer
Dim yr As Integer
yr = InputBox("Enter the year:", "Year")
quarter = InputBox("Enter the quarter (just the number):", "Quarter")
If quarter <> 1 Then
' open new quarter file
Workbooks.Open Filename:= _
"J:\recoding\report_002\Report002_" & yr & "Q" & quarter & ".xls", UpdateLinks:=0
' open old quarter file
Workbooks.Open Filename:= _
"J:\recoding\report_002\Report002_" & yr & "Q" & (quarter - 1) & ".xls", UpdateLinks:=0
'insert a row and a column at the most upper LHS
Windows("Report002_" & yr & "Q" & (quarter - 1) & ".xls").Activate