Calling Worksheet Change Event Directly from VBA

biocentrism

Board Regular
Joined
Jul 28, 2014
Messages
187
Is there a way to call a Worksheet Change Event using code?

I want to have the Worksheet Change Event execute as if the event actually occurred.

I have tried:
Code:
Call Worksheet_Change

but of course this did not work.

I read online that this was not possible. But I neither believe nor like this answer.

Thank you.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Why do you want to call it? That sounds like your code should be in a normal module and called from Worksheet_Change and from your current routine.
 
Upvote 0
Why do you want to call it? That sounds like your code should be in a normal module and called from Worksheet_Change and from your current routine.

The reason I want to do this is in effort to resolve another issue which I posted here.
http://www.mrexcel.com/forum/excel-...r-up-down-buttons-multiple-event-firings.html

Basically, when I click the Spinner Button Event to increment the date, it somehow triggers 20+ Worksheet_Change Events. But when I trigger the Worksheet_Change Event directly by manually changing the date, everything works fine.

So I am thinking that if I have the Spinner Button Event call the Worksheet_Change Event then it will work without the 20+ triggers.

Does this make sense?
 
Upvote 0
Upvote 0
The code in that thread shouldn't trigger any events since you disabled them, but you didn't post the code for the routine it calls (UpdateDashboard).
 
Upvote 0
The code in that thread shouldn't trigger any events since you disabled them, but you didn't post the code for the routine it calls (UpdateDashboard).

The other routine calls 3 other routines. But the routines are not relevant since these same routines are called by the Worksheet Change event.

You see whether I change the date manually or use a spinner to change the date, it results in the same validation and routines being called. What I cannot figure out is why a manual change works just fine and a Spin Event triggers 20 Change Events.

If the Routine when called by the Spin Event triggers 20 changes also triggered 20 changes when called by the Change Event, I would suspect there is something wrong with the Routine. But since the routine is the same, the problem must lie with the Spin Event?

I have also notice that sometimes when I click the Spin button once, it will trigger the Spin Button Click Events 2 to 5 times. I have a debug.print every time the Sub is called and for no apparent reason it machine gun fires 2-5 Button Click Events per click.

This is why I suspect there may be a glitch in the button.

Are the ActiveX buttons known to have problems?
 
Upvote 0
The code in that thread shouldn't trigger any events since you disabled them, but you didn't post the code for the routine it calls (UpdateDashboard).

In thinking more about it, there must be something in the Routine which is triggering the Change_Event. But for some reason if the Routine is called within the Change_Event it must not be treated as a "Change", whereas, if it is called from somewhere else it is treated as a Change.

I don't know if this is correct but it seems intuitive to me.

If this is the case, then having the Spin Button Click event calling the Change_Event should solve the problem.
 
Upvote 0
Ok I figured out the problem. It was the ActiveX Spinner Button. On a lark I tried using the Forms button (which unfortunately points up and down, not left and right). It works perfectly!

So it seems the ActiveX controls are unpredictable.

Wish I had tried this 2 days ago!
 
Upvote 0
ActiveX controls on worksheets have always been buggy. If you have to use them, I generally recommend you do not link them to cells directly (no LinkedCell/ListFilRange) since you'll often find their events triggered when you don't necessarily expect them to be. Was your Spinner linked to a cell?

To answer your original question here, yes you can call the Change event directly but you have to pass a Range object as parameter. Since your spinner was ActiveX and therefore its code is in the same worksheet module, you could simply use:
Code:
    Worksheet_Change Range("A1")
for example. From a normal module you could use:
Code:
    Application.Run "Sheet1.Worksheet_Change", Sheet1.Range("A1")
or you could make the change event routine public and call it directly.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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