Hey guys
Struggling with a bit of code to automatically clear the status cells. I have created a a true/false cell for when "true" is present that the status cells should be cleared.
I currently have a basic if statement but it is not triggering, any help would be much appreciated
Sub CheckIt()
If Range("G5") = "TRUE" Then Range("O9").ClearContents
End Sub
vba code for clearing cells when race goes IP
Right click on the sheet tab and select 'view code' and put this in
Note: It's case sensitive, so "True" wouldn't be recognised.
Code: Select all
Private Sub Worksheet_Calculate()
If Range("G5") = "TRUE" Then
Application.EnableEvents = False
Range("O9").ClearContents
Application.EnableEvents = True
End If
End Sub
-
- Posts: 6
- Joined: Fri Jul 28, 2017 1:37 pm
Thanks heaps for the reply Nigel! I've give it a go!
- ShaunWhite
- Posts: 9731
- Joined: Sat Sep 03, 2016 3:42 am
Doesn't this get executed whenever anything changes anywhere if AutoRecalc is set in the options ?nigelk wrote: ↑Mon Apr 23, 2018 11:43 amRight click on the sheet tab and select 'view code' and put this in
Note: It's case sensitive, so "True" wouldn't be recognised.Code: Select all
Private Sub Worksheet_Calculate() If Range("G5") = "TRUE" Then Application.EnableEvents = False Range("O9").ClearContents Application.EnableEvents = True End If End Sub
I found that Guardian updates so many fields this method tended to slow things down. It's why I changed to checking only the fields I was interested in, once every 200ms or 1s or 5s or whatever.
- ShaunWhite
- Posts: 9731
- Joined: Sat Sep 03, 2016 3:42 am