Run Macro if values are changing

mem_dawg

New Member
Joined
Oct 30, 2011
Messages
38
Hi All,

I have a code that clears the content of a cell if the value of that cell exceeds two.

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Cells(1, 1).Value > 2 Then Cells(1, 1).ClearContents
End Sub

My problem is the value of this cell comes from a function and changes every second automatically (linked to a data feed). So I'm not changing it manually, therefore my code is not working unless I touch it. I just wanted to ask if I can add a code onto this which checks the values and runs the ClearContents macro if there is any change.. I've got a few sheets like this so I need this to run in the background.. any help would be highly appreciated..

cheers,
mem
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try this instead

Code:
Private Sub Worksheet_Calculate()
If Cells(1, 1).Value > 2 Then Cells(1, 1).ClearContents
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,016
Members
449,280
Latest member
Miahr

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