View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Selecting worksheets into groups?

Probably not significant, but just some added information, this assumes
either no option base is specified and thus the default is 0 or that option
base 0 is specified.

Dim intInc as Long, intCnt as Long, Sheets4Printing() as Long

Redim Sheets4Printing(0 to 0)
intInc = 0
For intCnt = 1 to ThisWorkbook.Sheets.Count
'''Code to determine whether the sheet is added or not
redim Preserve Sheets4Printing(0 to intInc)
Sheets4Printing(intInc) = intCnt
intInc = intInc + 1
Next
' you can go directly to printout
Sheets(Sheets4Printing).PrintOut

would eliminate that concern. Also, Sheets(intCnt).Index is redundant as
this should equal intCnt

--
Regards,
Tom Ogilvy


"OJ" wrote in message
oups.com...
Hi,
try declaring a variable like this

Dim intInc as Long, intCnt as Long, Sheets4Printing() as Long

For intCnt = 1 to ThisWorkbook.Sheets.Count
'''Code to determine whether the sheet is added or not
redim Preserve Sheets4Printing(intInc)
Sheets4Printing(intInc) = Sheets(intCnt).Index
intInc = intInc + 1
Next
Sheets(Sheets4Printing).Select

This adds the sheet indexes to an array which can then be used...
Hth,
OJ