#1
|
|||
|
|||
Run Macro
I know that we can configure the macro to be run automatically once we open the xls file of by asking the user to click a specific button that trigger the macro.
However, I need to run the micro once the user enters a specific value in specific cell. I heard about event macros and I do not know if it can solve this issue and how. I appreciate any help. Thank you. |
#2
|
||||
|
||||
Hi ibrahimaa,
You could use a 'Worksheet_SelectionChange' macro like the following in the relevant worksheet's code module: Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.Address = "$A$3" Then If Target.Value = 123 Then Application.EnableEvents = False 'Call your other macro here Application.EnableEvents = True End If End If End Sub Code:
Private Sub Worksheet_Calculate() If ActiveCell.Address = "$A$3" Then If ActiveCell.Value = 123 Then Application.EnableEvents = False 'Call your other macro here Application.EnableEvents = True End If End If End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
There is also the Worksheet_Change() function which will trigger when cells on the worksheet are changed by the user or by an external link. Note however that this event does not occur when cells change during a recalculation.
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do I assign a macro to a button when the macro is in my personal workbook? | foolios | Excel Programming | 2 | 07-27-2011 02:41 PM |