ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Event code to continuously monitor change (https://www.excelbanter.com/excel-programming/375586-event-code-continuously-monitor-change.html)

Ybor Tony

Event code to continuously monitor change
 
I need to continuosly monitor whenever the value of cell b1 equals or does
not equal the value of cell c1 and when it's not equal then run a macro. i
have found several answers here to similar questions but the code runs only
one time and will not activate again if the value changes back to equal and
then not equal again.

Thanks,
Ybor Tony

Bob Phillips

Event code to continuously monitor change
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ybor Tony" <Ybor wrote in message
...
I need to continuosly monitor whenever the value of cell b1 equals or does
not equal the value of cell c1 and when it's not equal then run a macro.

i
have found several answers here to similar questions but the code runs

only
one time and will not activate again if the value changes back to equal

and
then not equal again.

Thanks,
Ybor Tony




Alok

Event code to continuously monitor change
 
Hi,

In the worksheet change event of the Sheet1 type the following

If Target.Cells(1).Address = "$B$1" Or Target.Cells(1).Address = "$C$1"
Then
If Sheet1.Cells(1, 2).Value < Sheet1.Cells(1, 3) Then
'macro name goes here
End If
End If


"Ybor Tony" wrote:

I need to continuosly monitor whenever the value of cell b1 equals or does
not equal the value of cell c1 and when it's not equal then run a macro. i
have found several answers here to similar questions but the code runs only
one time and will not activate again if the value changes back to equal and
then not equal again.

Thanks,
Ybor Tony


Sandy

Event code to continuously monitor change
 
Here you go this will fire if either B1 or C1 is changed


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B1:C1")) Is Nothing Then
If Range("B1").Value = Range("C1").Value Then
Application.EnableEvents = False
'<your true code here'
End If
End If
Application.EnableEvents = True
End Sub

Sandy



Ybor Tony wrote:
I need to continuosly monitor whenever the value of cell b1 equals or does
not equal the value of cell c1 and when it's not equal then run a macro. i
have found several answers here to similar questions but the code runs only
one time and will not activate again if the value changes back to equal and
then not equal again.

Thanks,
Ybor Tony




All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com