Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting worksheets into groups?

How can I use VBA code to add worksheets to or subtract worksheets from
groups?

The problem occurs when users select several sheets for printing, when some
of the sheets are not to be printed. I would like to remove one or more
sheet from group before print dialog shows.

I'm fine with a solution making me dissolve the entire group and then
building the correct group, but cant get it to work.

Have found code that let me create a group from scratch:
This works:
Sheets(Array("Week_01", "Week_02")).Select

But this doesn't:
MyString = """ & "Week_01" & """, """ & "Week_02" & """
Sheets(Array(MyString)).Select

Conclusion this far:
Hardcoding the array works but making it flexible is hard.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Selecting worksheets into groups?

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Selecting worksheets into groups?

Good point Tom....you're always adjusting my posts for the better!! ;o)

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
Excel 2007 - change shading when selecting groups of cells [email protected] Excel Discussion (Misc queries) 1 April 7th 08 03:58 AM
selecting cell groups and locking up Bugged by Excel? Excel Discussion (Misc queries) 3 August 4th 05 01:07 PM
Selecting WorkSheets Jordan Excel Programming 3 February 25th 05 07:10 PM
Selecting in groups within a sort shawb Excel Programming 1 September 8th 04 01:29 PM
selecting worksheets Matthew Kramer Excel Programming 1 August 16th 04 10:39 PM


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