Forum Discussion
Running macro using buttons is causing problems with menus
Hi, Hopefully someone has seen this problem before.
I have an Excel workbook which has some buttons (shapes) that have macros assigned to them, which switch between worksheets.
If I run the macros from Visual Basic window (run, not step into) it works well. These exact same macros have been assigned to buttons in the worksheets. If I click them to switch between the sheets, after a few clicks the menus (such as changing font, clicking on my user information, sort/filter) become disabled. I am able to click on the menus but then a shadow like box of what should be displaying shows up (attached image showing when I click on my user info). And even more strange, it is just on certain sheets.
I can confirm the workbook and worksheets are not protected. Some of the worksheets have Worksheet_Change subs but I get the same problem on sheets that do not. The only ThisWorkbook sub I have relates to BeforeSave.
Any help would be appreciated.
5 Replies
- JKPieterseSilver ContributorCan you share some of the relevant code please?
- joeSKHCopper Contributor
JKPieterse Many thanks for your interest.
I have made a scaled down version of my file which I have attached, which highlights the problem I am having. From my testing, it would suggest that Excel has a problem when switching sheets between visible and invisible when a macro is used to run using a button that is a shape or a form control.
In the attached, the main sheet has multiple ways of switching to page 1 and page 2. The first set of buttons are shapes. The second set form controls. The third set ActiveX controls. The fourth set are using the Worksheet_SelectionChange.
Use the Shapes or Form Controls, try clicking to go to page 1, then come back, then go to page 2 and then come pack. You should find the many of the menu items are not working. But if you run the macros by using the ActiveX controls, the Worksheet_SelectionChange or other manual ways of running the macros, I dont seem to have the same problems.
I tested the Shapes or Form Controls buttons, where the macro did not need to make the sheets visible/invisible and the problem with the menus did NOT exist. Hence I think it relates to the changes to the visibility.
I am using Windows 10 64 bit, all updates done. Office365 32bit, all updates done.
- JKPieterseSilver ContributorI don't see any weirdness on my end. It all works as expected.
What happens if you launch Excel in safe mode and then try?