![]() ![]() The idea is to have a new procedure Sheet1_Activate that takes the actual code and is triggered by the Worksheet_Activate as well as by the Workbook_Open in case the sheet is already the active sheet. ThisWorkbook.Worksheets("Sheet1").Activate In Sheet1 write: Private Sub Worksheet_Activate()Īnd in ThisWorkbook write: Private Sub Workbook_Open() Write in a module: Public Sub Sheet1_Activate() Now open it again, it will run Worksheets("Sheet1").Activate and this will trigger the Worksheet_Activate properly.Īlso note that MsgBox ("hello") should be without parenthesis as it does not return a value to a variable: MsgBox "hello" Then select Sheet2 save the file and close it. ![]() Test it by adding 2 Sheets Sheet1 and Sheet2. We activated the worksheet by refering the worksheet object. Because you cannot activate what is already active. If Sheet1 is already active when you open the workbook, then Worksheets("Sheet1").Activateĭoes exactly nothing. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |