Macro Error 1004 - Unable to set the visible property of the worksheet class

efire_

New Member
Joined
Aug 8, 2014
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello! On the very last stages of finalizing an xls, and just can't figure out this last error. The gist of it: on a "Master" sheet, I can select via checkbox which sheets I'd like to be in a PDF. At the bottom there's a "Print" button. When clicked, a macro runs that hides all sheets with unchecked boxes, generates a PDF with all the remaining sheets, then unhides everything and opens the PDF.

That all was working great - then I did some row changing / small formatting, and this error message pops up when the Print button is clicked: "Error 1004 - Unable to set the visible property of the worksheet class". I hit Debug and it takes me to this line of code:

Sheets("Master").Visible = xlSheetHidden

And no, nothing in the workbook is protected (saw that fix on Google). And I get that excel has to leave one sheet visible at all times (it hides the Master sheet when the Print button is selected), but then why would that error appear when I have clearly checked the boxes to leave other sheets visible?

Any help would be hugely appreciated. Thanks a ton in advance!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
18,069
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Have you tried stepping through the code using the F8 key and when you get the error, hit Debug and look at the workbook to see if any sheets other than Master are visible?
 
Upvote 0

Forum statistics

Threads
1,191,484
Messages
5,986,856
Members
440,053
Latest member
jhollingworth

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
Top