Using Excel 2002 I have a macro which copies data from one spreadsheet, opens another spreadsheet, copies the records to the spreadsheet that was opened, and this closes that spreadsheet after the paste.
It is possible for the user to already have that spreadsheet open. I have found code that is able to verify the spreadsheet is already open. What I want to do is, if the spreadsheet is already open run my procedure that pastes the records and closes the spreadsheet, but if the spreadsheet is not already open, have the macro do what it does now, open the spreadsheet, paste the records, then close the spreadsheet.
The later is working fine. My problem is with the former. I get a message stating subscript out of range. I suppose that means I am referencing the workbook/spreadsheet incorrectly, but I am not sure how to fix it.
Thanks
It is possible for the user to already have that spreadsheet open. I have found code that is able to verify the spreadsheet is already open. What I want to do is, if the spreadsheet is already open run my procedure that pastes the records and closes the spreadsheet, but if the spreadsheet is not already open, have the macro do what it does now, open the spreadsheet, paste the records, then close the spreadsheet.
The later is working fine. My problem is with the former. I get a message stating subscript out of range. I suppose that means I am referencing the workbook/spreadsheet incorrectly, but I am not sure how to fix it.
Code:
ServicerFolder = wsMainMenu.Range("G5").Value
RemittanceMonth = Left(wsMainMenu.Range("G4").Value, 2)
RemittanceYear = Mid(wsMainMenu.Range("G4").Value, 3, 4)
ChDir ServicerFolder
If IsFileOpen(ServicerFolder & "\monthlyremittance.xls") Then
[b]Windows(ServicerFolder & monthlyremittance.xls).Activate[/b]
Else
Workbooks.Open filename:=ServicerFolder & "\monthlyremittance.xls"
End If
Thanks