Change a VBA to run automatically or when moving tabs

DMO123

Board Regular
Joined
Aug 16, 2018
Messages
99
Hi All,

i have the below VBA which only runs when the cell is updated. there is a formula that updates the cell but the VBA is not picking this up as a change. how do i get the VBA to run automatically so i dont have to tab inside each cell to make the VBA run. preferably fully automatic but if its easy can be a change of tab etc.

any help would be appreciated.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)    If Target.Column = 9 Or Target.Column = 13 Then 'Column I or column M
       If UCase(Target) = "YES" Then Target.Offset(0, -1).ClearContents
    End If
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You could use the Calculate event instead of the Change event.

Alternatively if the formula you are trying to run this code for has references to cells where is manual input you could you could check for those cells being changed.
 
Upvote 0
@Norie - thanks. if im understanding this correctly i update
Code:
[COLOR=#333333]Private Sub Worksheet_Calculate(ByVal Target As Range)[/COLOR]
?

if this is correct i got the below error:
"Procedure declaration does not match description of event or procedure having the same name"
 
Upvote 0
Unfortunately not.

The Calculate event is triggered whenever the sheet calculates and doesn't have a Target argument.

That's kind of one of the problems with using that event. it'll be triggered by the calculation of formulas that have nothing to do with the one you are interested.
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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