Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Excel macro full cell reference (https://www.askmehelpdesk.com/showthread.php?t=434283)

  • Jan 11, 2010, 07:02 PM
    ExcelLarry
    Excel macro full cell reference
    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).
  • Jan 11, 2010, 10:38 PM
    JBeaucaire

    Two answers:

    1) You never have to activate a sheet to make changes on it. Just give the full sheet/range/instruction
    Code:

    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:
    Code:

    Application.EnableEvents = False

    ' your code here

    Application.EnableEvents = True


  • All times are GMT -7. The time now is 06:31 PM.