Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Print visible sheets - ordering



Hi Guys,

I have simple VB that prints all sheets in my workbook - see below.
Problem is that the order that it prints the sheets is not the way they
are visible - For example it prints Appendix G before Appendix A, yet A
is visible before G. To complicate Matters there are hidden sheets
(which it ignores). So question, how can I tell Excel the order of
sheets to print, or just to print them as they are visible, instead of
when they were created? (I'M assuming appendix G was created before
appendix A)

Regards

D

Sub PrintVisibleSheets_2()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
If ws.Name < "Grading_guid" Then
ws.PrintOut Copies:=1, Collate:=True
End If
End If
Next
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Print visible sheets - ordering

Hi Darin:

Try using a for loop and stepping through the serquence as in the following

Sub PrintVisibleSheets_2()

dim lShtNr as long
dim ws as worksheet
with ActiveWorkbook
For lShtNr= 1 to .Worksheets.count
set ws = .worksheets(lShtNr)
If ws.Visible = xlSheetVisible and ws.Name < "Grading_guid" Then
ws.PrintOut Copies:=1, Collate:=True
End If
Next lShtNr
End With
End Sub


--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Darin Kramer" wrote:



Hi Guys,

I have simple VB that prints all sheets in my workbook - see below.
Problem is that the order that it prints the sheets is not the way they
are visible - For example it prints Appendix G before Appendix A, yet A
is visible before G. To complicate Matters there are hidden sheets
(which it ignores). So question, how can I tell Excel the order of
sheets to print, or just to print them as they are visible, instead of
when they were created? (I'M assuming appendix G was created before
appendix A)

Regards

D

Sub PrintVisibleSheets_2()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
If ws.Name < "Grading_guid" Then
ws.PrintOut Copies:=1, Collate:=True
End If
End If
Next
End Sub

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Print visible sheets - ordering



WORKS PERFECTLY - THANKS!

*** Sent via Developersdex http://www.developersdex.com ***
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
Ordering of sheets in a workbook T New Users to Excel 4 May 12th 09 08:00 AM
Print Visible Sheets Macro Lisa C. Excel Discussion (Misc queries) 1 April 6th 09 06:08 AM
Visible sheets Steph[_6_] Excel Programming 2 January 31st 06 10:38 PM
Autoshapes not visible on spreadsheet but visible in print preview John Excel Discussion (Misc queries) 3 February 11th 05 10:23 PM
Need Help w/ Print Macro to Print All Visible Sheets (including Charts) in a Workbook will Excel Programming 3 September 23rd 04 08:05 PM


All times are GMT +1. The time now is 07:43 AM.

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

About Us

"It's about Microsoft Excel"