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

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.
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,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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