Command Button Macro not fully running

GeoM

New Member
Joined
Mar 31, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Created a macro that will unhide 10 worksheet tabs based on a range reference. Macro works successfully in opening all 10 worksheets when run via macro window. But when I assign the macro to a command button the macro stops after two iterations in the middle of the process. If I click the button again it will only execute 2 iterations at a time on each button click. Below is a screenshot of macro. Using excel 365.

1648749927131.png
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Please please please paste your code into your post instead of showing a picture of it. If I am going to reproduce your problem I have to type all this in from scratch.

What module contains this code?
What worksheet contains the button?

Do not rely on what sheet is active. Be explicit:

VBA Code:
With Worksheets("notes")
   While .Cells(iNum1, 12).Value <> ""
      Worksheets(.Cells(iNum1, 12).Value).Visible = True
      iNum1 = iNum1 + 1
   Loop
End With

I am not sure that is causing your problem, hard to tell if I do not have your file for testing. But I suggest giving it a try.
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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