Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default Excluding worksheets from printing

Hi,

I currently embed an Excel macro in my spreadsheets which will print
the entire workbook (40+ sheets) should the user request it:

Private Sub CommandButton2_Click()
Dim Sheet As Worksheet
Dim lAnswer As Long
lAnswer = MsgBox("This report contains " & Sheets.Count & " sheets - Do
you want to print them all?", vbYesNo, "Print?")
If lAnswer = vbNo Then
Exit Sub
Else
Worksheets.Select
Application.Dialogs(xlDialogPrint).Show
Sheets("Total").Select
End If
End Sub


However, I have now incorporated several workings sheets that are
hidden which I do not want to be printed - the only problem is I don't
know how to alter the above code to exclude the sheets (called "Input"
and "Workings"). Can anybody help?

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Private Sub CommandButton2_Click()
Dim Sheet As Worksheet
Dim lAnswer As Long
Dim lSheet As Long
Dim sh As Worksheet
Dim arySheets
lAnswer = MsgBox("This report contains " & Sheets.Count & _
" sheets - Do you want to print them all?", vbYesNo, "Print?")
If lAnswer = vbNo Then
Exit Sub
Else
ReDim arySheets(1 To 1)
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = xlSheetVisible Then
lSheet = lSheet + 1
ReDim Preserve arySheets(1 To lSheet)
arySheets(lSheet) = sh.Name
End If
Next sh
Worksheets(arySheets).Select
Application.Dialogs(xlDialogPrint).Show
Sheets("Total").Select
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
oups.com...
Hi,

I currently embed an Excel macro in my spreadsheets which will print
the entire workbook (40+ sheets) should the user request it:

Private Sub CommandButton2_Click()
Dim Sheet As Worksheet
Dim lAnswer As Long
lAnswer = MsgBox("This report contains " & Sheets.Count & " sheets - Do
you want to print them all?", vbYesNo, "Print?")
If lAnswer = vbNo Then
Exit Sub
Else
Worksheets.Select
Application.Dialogs(xlDialogPrint).Show
Sheets("Total").Select
End If
End Sub


However, I have now incorporated several workings sheets that are
hidden which I do not want to be printed - the only problem is I don't
know how to alter the above code to exclude the sheets (called "Input"
and "Workings"). Can anybody help?



  #3   Report Post  
 
Posts: n/a
Default

Thank you!!!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing Landscaped and Portrait worksheets at same time...XP Tamela Excel Discussion (Misc queries) 0 June 7th 05 01:14 AM
Printing multiple worksheets on one page Ben :Dillon Excel Discussion (Misc queries) 1 April 6th 05 11:02 PM
Excel - printing multiple worksheets on one page BGA Excel Discussion (Misc queries) 1 February 18th 05 02:05 PM
printing an array of worksheets Marco de Witte Excel Discussion (Misc queries) 4 December 8th 04 03:21 PM


All times are GMT +1. The time now is 09:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"