Link Cell To Run Macro

nehpets12

Active Member
Joined
Feb 22, 2002
Messages
453
Is It Possible to Only Run A Macro If A Cell With A Formula Changes?
Book1
ABCDEFGHI
108-Nov06-Nov07-Nov08-Nov09-Nov
210-Nov11-Nov12-Nov13-Nov14-Nov
3
406-NovHowDoIGetAMacroToRunOnlyWhenTheCellA4Changes
5IDontWantItToRunEveryTimeIChangeAValueInTheAboveDates
6OnlyRunWhenTheChangesAffectCellA4
7
8
Sheet1
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi nehpets12

Try this:

Declare a Public variable in a normal module, eg Module1 : Public MyFlag As Variant.

Then use this:

<pre>Private Sub Workbook_Open()
MyFlag = Sheets(1).Range("A4").Value
End Sub

Private Sub Worksheet_Calculate()
If MyFlag <> Range("A4").Value Then MsgBox "A4 has changed!"
MyFlag = Sheets(1).Range("A4").Value
End Sub</pre>
HTH
 
Upvote 0
Hi;

Similar to Richie's answer but, you can also try this;

Dim Data

Private Sub Worksheet_Activate()
Data = [A4]
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If [A4] <> Data Then YourMacro
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top