Print hidden sheets -

GregoryT

New Member
Joined
Oct 30, 2019
Messages
13
I used the following code to print a hidden sheet and my first sheet disappeared .......can anyone tell me what the problem was, please

TIA
GT

Sub PrintOnlyHiddenWorksheets()
Dim CurVis As Long
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
With sh
CurVis = .Visible
If CurVis >= 0 Then
.Visible = xlSheetVisible
.PrintOut
.Visible = CurVis
End If
End With
Next sh
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Works fine for me !!
By disappeared, do you mean hidden , deleted ??

Code:
Sub PrintOnlyHiddenWorksheets()
Dim CurVis As Long, sh As Worksheet
For Each sh In Worksheets
    With sh
    CurVis = .Visible
        If CurVis >= 0 Then
            .Visible = xlSheetVisible
            .PrintOut
            .Visible = CurVis
        End If
    End With
Next sh
End Sub
 
Upvote 0
The sheet gets erased, I am attempting to upload the workbook so you can have a look, but I cant see where to upload it.

Need coffee lol

Thanks
 
Upvote 0
You can't attach files in this forum.
I'd suggest looking at available options here
OR
Upload your file to a sharing site, Dropbox for instance, and then post the link back here
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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