I have an Excel workbook that executes a macro when being opened. During the process the macro creates a number of worksheets and then saves itself and closes.
Prior to saving I would like a certain worksheet to be selected. So if I ever was to open the workbook I don't have to change worksheets.
This code usually works well...
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sometimes there are 2 or more workbooks open at once.
If the workbook is not selected when the macro runs this error is generated...
"Object doesn't support this property or method" for this line ThisWorkbook.Worksheets("C
How can I work around this? I want the macro to set "Create Report" as the active/selected sheet in the workbook and then close it without the workbook itself having to be the focused/active window.