Print a Single Hidden Worksheet?

S

SSDSCA

I have a dynamic workbook with two hidden sheets named "Lists" and "Day
Cost". The only way I can, at present, print out the "Day Cost" sheet is to
leave it unhidden, however I would prefer to have it hidden as it has
formulas that pull the information from the other visible sheets. Can
somebody help me with a macro that would allow me to have both the "Day Cost"
and "Lists" sheet remain hidden and only print "Day Cost" out.
 
J

JLGWhiz

I believe the sheet has to be visible but you can use a sequence like the one
below to print the sheet and it is only visible for an instant.

Sub prtSeq()
Sheets("Day Cost").Visible = True
Sheets("Day Cost").PrintOut
Sheets("Day Cost").Visible = False
End Sub
 
G

Gary Keramidas

you can give this a try, just change the print parameters

Option Explicit
Sub printHidden()
Dim ws2 As Worksheet
Dim lastrow As Long
Application.ScreenUpdating = False
Set ws2 = Worksheets("Lists")
lastrow = ws2.Cells(Rows.Count, "A").End(xlUp).Row


With ws2.PageSetup
.PrintTitleRows = "$1:$1"
.Orientation = xlPortrait
.PrintGridlines = True
.Zoom = 90
.RightMargin = Application.InchesToPoints(0.4)
.LeftMargin = Application.InchesToPoints(0.4)
.TopMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.5)
.RightFooter = "Page " & "&P" & " of " & "&N"
.RightHeader = "&B&12 " & Date
.PrintArea = "A2:M" & lastrow
.CenterFooter = ""
.FooterMargin = Application.InchesToPoints(0.3)
End With

If ws2.Visible = 0 Then
ws2.Visible = -1
ws2.PrintPreview
ws2.Visible = 0
End If
Application.ScreenUpdating = True
End Sub
 
P

Per Jessen

Hi Don

Try this:

Sub PrintHiddenSheets()
Application.ScreenUpdating = False
With Sheets("Lists")
.Visible = True
.PrintOut
.Visible = False
End With
With Sheets("Day Cost")
.Visible = True
.PrintOut
.Visible = False
End With
Application.ScreenUpdating = True
End Sub

Regards,
Per
 
S

SSDSCA

Thanks guys. you can't imagine how much I have learned from not only your
responses but by all the responses that are posted. You are appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top