Ask Experts Questions for FREE Help !
Ask
    ExcelLarry's Avatar
    ExcelLarry Posts: 1, Reputation: 1
    New Member
     
    #1

    Jan 11, 2010, 07:02 PM
    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).
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

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

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Excel Macro [ 13 Answers ]

I have some code that loops through a row and a column and compares data. When it finds the values being equal it copies the columns the row is in and pastes it on another sheet along with the previous value of the column. For Each CCell In Range("C2:C65418") If Not IsEmpty(CCell.Value)...

Excel macro [ 4 Answers ]

I need to run a macro that opens excel so I can kick off "application.ontime" basically my macro should run without me having to start excel, just have the computer and outlook running. Is that possible?

Start excel with a macro [ 3 Answers ]

How can I start excel with a macro.

Cell references within VBA in an Excel macro [ 1 Answers ]

In a macro in Excel I want to refer to a cell where the user entered a number. I want that number to be the row number for the macro to move to. (I will then select the entire row and copy it to row 1, which I know how to do). How can I tell the macro which row to go to, using the number...

Recording a macro in Excel [ 2 Answers ]

Need a macro that will select the cell one place to the left, edit the content, hit enter, and then move to cell below where started and repeat to end of column (last cell with a value). Example: 123-456789 is format of cell to be edited - need to remove the hyphen. Someone had created it...


View more questions Search