ExcelLarry
Jan 11, 2010, 07:02 PM
I am running a macro when the sheet is opened. In my macro I want to reference a cell on a different sheet without selecting that sheet. In other words I do not want to leave the Active sheet (call it Sheet1) and return to the Sheet1 which will "Activate" the Sheet1 again, triggering my macro again (infinite loop).
JBeaucaire
Jan 11, 2010, 10:38 PM
Two answers:
1) You never have to activate a sheet to make changes on it. Just give the full sheet/range/instruction
Sheets("Sheet2").Range("A1").Value = "Done"
2) You can disable macros at the beginning of the active macro so it CAN move around safely without triggering further macros until you instruct Excel that other macros are OK again:
Application.EnableEvents = False
' your code here
Application.EnableEvents = True