![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 27
|
How can I create a condition to run a macro after a particular cell is modified? The best I've done so far is to run the macro after any cell on a sheet has been modified.
Thanks, Bidwin |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Helena, MT
Posts: 13,690
|
I think your're on the right track. Use the WorkSheet Change Event. Use an IF Statement, such as If Target.Address="$A$4" Then 'Your Macro'.
This will run only when the designated cell is changed |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Huntington Beach, CA USA
Posts: 327
|
Heres 2 Examples:
SubTryThis() Dim MyMacro As String [A1] = "Hello" MyMacro = [A1] Run MyMacro End Sub Sub Hello() MsgBox"Hello" End Sub Or.............. Private Sub Worksheet_Calculate() If Me.Range("A1") = "" Then YourMacro End Sub Sub YourMacro() MsgBox "A1 is empty!" End Sub Your macro could either be in the worksheet code module or in a standard module James |
|
|
|
|
|
#4 |
|
New Member
Join Date: Apr 2002
Posts: 27
|
lenze and James, Thanks for your replies. Both were very helpful. I got the macro to do what I intended it to do.
bidwin |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|