Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ant
 
Posts: n/a
Default Print question - Calling Dave Peterson!

I saw this handy code on Ron Debruin's page which prints all hidden and
unhidden pages.

'Dave Peterson
Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = curVis
End With
Next sh
End Sub

Is it possible to incoporate some additional code which excludes some
sheets. Basically I have a report and I want to print all the pages (some
hidden) except the large data dump sheet. Lets say the sheet is called 'Data'.

Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Print question - Calling Dave Peterson!

Try something like the following:

Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
Select Case sh.Name
Case "Data1", "Data2", "Data3"
' ignore these sheets
Case Else
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = curVis
End Select
End With
Next sh


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ant" wrote in message
...
Thanks Tom. What would need adding if I actually had three
(maybe more)
sheets I wanted excluded, say 'Data1', 'Data2', Data3'.

"Tom Ogilvy" wrote:

'Dave Peterson
Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
if lcase(sh.name) < "data" then
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = curVis
end if
End With
Next sh
End Sub

--
Regards,
Tom Ogilvy



"Ant" wrote:

I saw this handy code on Ron Debruin's page which prints all
hidden and
unhidden pages.

'Dave Peterson
Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = curVis
End With
Next sh
End Sub

Is it possible to incoporate some additional code which
excludes some
sheets. Basically I have a report and I want to print all
the pages (some
hidden) except the large data dump sheet. Lets say the sheet
is called 'Data'.

Is this possible?



  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Print question - Calling Dave Peterson!

And if you wanted to always ignore the sheets that start with data:

Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
if left(lcase(sh.name),3) < "data" then
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = curVis
end if
End With
Next sh
End Sub

Ant wrote:

Thanks Tom. What would need adding if I actually had three (maybe more)
sheets I wanted excluded, say 'Data1', 'Data2', Data3'.

"Tom Ogilvy" wrote:

'Dave Peterson
Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
if lcase(sh.name) < "data" then
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = curVis
end if
End With
Next sh
End Sub

--
Regards,
Tom Ogilvy



"Ant" wrote:

I saw this handy code on Ron Debruin's page which prints all hidden and
unhidden pages.

'Dave Peterson
Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut
.Visible = curVis
End With
Next sh
End Sub

Is it possible to incoporate some additional code which excludes some
sheets. Basically I have a report and I want to print all the pages (some
hidden) except the large data dump sheet. Lets say the sheet is called 'Data'.

Is this possible?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
David McRitchie
 
Posts: n/a
Default Print question - Calling Dave Peterson!

correction for a typo, since the length of "data" is four, the test should be
if left(lcase(sh.name),4) < "data" then


  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Print question - Calling Dave Peterson!

Thanks for the correction....

(If I could count, I'd be dangerous!)

David McRitchie wrote:

correction for a typo, since the length of "data" is four, the test should be
if left(lcase(sh.name),4) < "data" then


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
Ant
 
Posts: n/a
Default Print question - Calling Dave Peterson!

One more question guys...

I would like the report to print out the pages in order. Currently they come
out (I guess) in the order that they are hidden. ie, the code below unhides
each sheet and prints it off so it comes out in that order. I have page
numbers on the footer and would ideally like them to print out in the
numerical order. Problem though is other people use this report, that allows
them to unhide and hide sheets at will, so this will always jumble up the
order.


"Dave Peterson" wrote:

Thanks for the correction....

(If I could count, I'd be dangerous!)

David McRitchie wrote:

correction for a typo, since the length of "data" is four, the test should be
if left(lcase(sh.name),4) < "data" then


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Print question - Calling Dave Peterson!

You could unhide the sheets, put them in numerical order, then hide them again.

If you have a lot of worksheets to put in order, then you may want to look at
Chip Pearson's site:
http://www.cpearson.com/excel/sortws.htm

Remember to name your sheets nicely:

Data001
Data002
....
Data999

If you name them
Data1
Data2
....
Data10
Data11

You'll have trouble getting the sort to work the way you want.

Ant wrote:

One more question guys...

I would like the report to print out the pages in order. Currently they come
out (I guess) in the order that they are hidden. ie, the code below unhides
each sheet and prints it off so it comes out in that order. I have page
numbers on the footer and would ideally like them to print out in the
numerical order. Problem though is other people use this report, that allows
them to unhide and hide sheets at will, so this will always jumble up the
order.

"Dave Peterson" wrote:

Thanks for the correction....

(If I could count, I'd be dangerous!)

David McRitchie wrote:

correction for a typo, since the length of "data" is four, the test should be
if left(lcase(sh.name),4) < "data" then


--

Dave Peterson


--

Dave Peterson
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
Print question - Calling Dave Peterson! Tom Ogilvy Excel Discussion (Misc queries) 1 March 27th 06 06:04 PM
Dave Peterson atxcomputers Excel Discussion (Misc queries) 12 September 28th 05 06:17 PM
Combo Box or Data Validation FA Excel Discussion (Misc queries) 17 September 27th 05 01:58 PM
Print Copy limit gocats Excel Discussion (Misc queries) 8 August 26th 05 01:33 AM
formula not working Micayla Bergen Excel Discussion (Misc queries) 13 May 23rd 05 01:48 PM


All times are GMT +1. The time now is 06:56 PM.

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"