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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Richie(UK)

MrExcel MVP
Joined
May 17, 2002
Messages
3,329
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
 

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
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
 

Forum statistics

Threads
1,144,058
Messages
5,722,269
Members
422,419
Latest member
Havok390

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
Top