active macro on new value

Status
Not open for further replies.

wonderboutin

Board Regular
Joined
Jan 7, 2005
Messages
77
I want active a macro is the Range("A1") have a new value.

"A1" = (=sheet2!B1) A1 is in sheet1

if I write a new value in sheet2!B1, sheet1!A1 have a new value and i want to active macro

I try this macro

Private Sub Worksheet_Change(ByVal Target As Range)
If MY_OLD_VALUE <> Range("A1") <> Value Then
'your code here
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MY_OLD_VALUE = Range("a1").Value
End Sub

but is good if I change the value of A1 but if A1 is a copy of a other cell, then macro is not activated

tanks :cry:
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I try the 2 macro on the other topic but is not what I want to do.

The fist macro

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
'your code here
End If
End Sub

active my macro only if I change the value of the cell ("A1") but if the cell ("A1") is a calcule or a copy of a other cell ex: =B2,
the macro is not activated



The second macro



Private Sub Worksheet_Change(ByVal Target As Range)
If MY_OLD_VALUE <> Range("A1") <> Value Then
'your code here
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MY_OLD_VALUE = Range("a1").Value
End Sub



active my macro if any value in the sheet in changed not only cell ("A1")
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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