- Joined
- Aug 11, 2011
- Messages
- 1
- Reaction score
- 0
I am having this error on an Excel report. I am running the code from an Excel form. The error only happens the first time I run the code each day. If I end the code and run it again, the report completes succesfully. The spreadsheet that I write to is an Excel template that has three worksheets. This error happens on the first iteration through a For Next loop as it tries to activate the first worksheet. I have an Excel object named XL1 and I have tried putting it in front of Sheets, but this did not fix the error. I tried setting the sheet to visible in a line before the error line and it gives the error on that line instead. Any help or suggestion would be welcomed.
Code snippet:
' Activate current worksheet.
Sheets(strWrkSheet(intCnt2)).Activate <--- ***Error happens here***
Set wks = ActiveSheet
Code snippet:
' Activate current worksheet.
Sheets(strWrkSheet(intCnt2)).Activate <--- ***Error happens here***
Set wks = ActiveSheet