Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Grouping and Printing Worksheets in Excel VBA

Hi all,

I'm trying to create a simple sub that will group a series of sheet
and print out the group. For example, if I have sheet1, sheet2, and
sheet3, I want the sub to select all three sheets and print them out
(not cycle them but select them.)

So, I can do this:

Sub Foo()
Worksheets(Array("Sheet1","Sheet2","Sheet3")).Prin tout
End Sub

but I can't understand why I can't do this:

Sub Foo2()
Dim i as Integer
Dim strSheets() as String
Dim r as Range

Set r = Range("ListOfSheetToPrintIsHere")

With r
ReDim strSheets(0 to .Cells.Count-1)
For i = 0 to .Rows.Count-1
strSheets(i)=.Cells(i).Value
Next
End With

Worksheets(strSheets).PrintOut

Erase strSheets()
Set r = Nothing
End Sub

I get an subscript out of range error on the Worksheets(strSheets....
line. I can't simply use the array functions for the sheets I want to
select and print because I don't know at design time what sheets the
user will want to group print.

Thanks,
Johnny

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Grouping and Printing Worksheets in Excel VBA

Please disregard this post. Turns out that one of the worksheets in
the list had the incorrect name. You can, in fact, pass an array of
strings to the Worksheets object, if you created it manually or
dynamically.

Thanks,
Johnny

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
Grouping on protected worksheets wnwilkerson Excel Worksheet Functions 4 April 22nd 10 09:15 PM
Printing Excel Worksheets Justme 61 Excel Discussion (Misc queries) 1 April 4th 08 10:07 PM
Grouping and moving worksheets by name using VBA? Simon Lloyd[_741_] Excel Programming 4 May 31st 06 08:13 PM
grouping hidden worksheets bennyob Excel Discussion (Misc queries) 5 November 5th 05 12:39 AM
printing worksheets in Excel BGA Excel Discussion (Misc queries) 1 February 17th 05 03:24 PM


All times are GMT +1. The time now is 10:17 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"