Worksheet_Activate() code not working

philwojo

Well-known Member
Joined
May 10, 2013
Messages
533
So I am working on a sheet for another group and it has the following code on a worksheet. But the code is not running at all when the sheet is activated.

It was originally just this code:

Code:
Private Sub Worksheet_Activate() Call UpdateCodes
End Sub

I updated it to this for testing and I never get a Message Box to pop up:

Code:
Private Sub Worksheet_Activate()ActiveSheet.Unprotect "xxxxx"
MsgBox "It is running"
 Call UpdateCodes
ActiveSheet.Protect "xxxx"
End Sub

Any thoughts on what could be causing the code not to run? I click out of the sheet and into another sheet and back again and nothing happens. Just trying to figure out what might be causing this one, seems it should be working to me.
 
Yea, I've tried that multiple time as well, and other people are having the issue also.

I appreciate the help and if anyone else has anything to try I'm willing to give it a go.

At least I have the button that can be used, better than no fix at all.
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You do understand:
You must activate another sheet and then activate this sheet with your code to get your code to run.

Just clicking on the tab will not activate the script
 
Upvote 0
OK, what do you mean by activate then, maybe I am not following what that term means? But I click on another tab and click in a cell, then click back to here and in a cell and still nothing.
 
Upvote 0
If you click on tab 2 and select some cell
Then click back on tab 1 and your script is in Tab 1 then the script should run.
Are you doing this manually or as part of another script?
 
Upvote 0
I do just that and nothing runs for this script. What I posted in here is all there is, it doesn't even give me the Message Box, let alone run the script it calls.
 
Upvote 0
Have you tried shutting down Excel.
Restart Excel and create a new workbook.
And try this again.

If you have other sheet change event code in your sheet show it to us
 
Upvote 0
No other even code changes of any kind. I have tried shutting down and restarting Excel, no change. I have not tried to recreate the entire workbook, no, that would take more time than I'm willing to put in to this, the button will be a good enough fix in that case.
 
Upvote 0
Create a New Workbook.
And post in just this code and see if it will work for you.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
Code:
Private Sub Worksheet_Activate()
MsgBox "It is running"
 
End Sub
 
Upvote 0
Yep, tried that just now and it did not do anything either, seems like it is something on this end that is limiting it.
 
Upvote 0

Forum statistics

Threads
1,215,241
Messages
6,123,823
Members
449,127
Latest member
Cyko

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