Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
add worksheet to group
I am looking for a way to add a worksheet to a group of
sheets that I will print using the "printpreview" method. I will add them if they meet certain requirements, which I've already worked out. I'm just looking for the method and an example to add the sheets to the group. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
add worksheet to group
Hi
Try this code. Exclude the sheets who should not be selected with your code, and ad them into the "non selectable" array: Option Explicit Sub Group_Selected_Sheets_in_Array_for_Printout() 'by Ramses 'Define Worksheets for a group Dim vWorksheet As Worksheet Dim vWorksheetsToSelect() As String Dim vWorksheetsToDeselect(2) As String Dim i As Byte Dim ii As Byte Dim vFound As Boolean 'Define Sheet who should not selected into group vWorksheetsToDeselect(0) = "Sheets1" vWorksheetsToDeselect(1) = "Sheets2" vWorksheetsToDeselect(2) = "Sheets3" ii = 0 'All other Sheets will be selected For Each vWorksheet In Worksheets vFound = False For i = 0 To UBound(vWorksheetsToDeselect) If vWorksheet.Name = vWorksheetsToDeselect(i) Then vFound = True Exit For End If Next i If Not vFound Then ReDim Preserve vWorksheetsToSelect(ii) vWorksheetsToSelect(ii) = vWorksheet.Name ii = ii + 1 End If Next vWorksheet 'Select Sheets in Array Sheets(vWorksheetsToSelect).Select End Sub If you have more than 255 sheets in your workbook, change Type of i an ii from Byte into Integer ;-) Best regards from switzerland :- -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
add worksheet to group
Hi Rich,
Here is some sample code to group the sheets, just change the criteria to yours Dim i As Long, j As Long Dim arySheets For i = 1 To Worksheets.Count If Left(Worksheets(i).Name, 5) = "Sheet" Then If j = 0 Then ReDim arySheets(0) Else ReDim Preserve arySheets(j) End If arySheets(j) = Worksheets(i).Name j = j + 1 End If Next i Worksheets(arySheets).Select -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Rich" wrote in message ... I am looking for a way to add a worksheet to a group of sheets that I will print using the "printpreview" method. I will add them if they meet certain requirements, which I've already worked out. I'm just looking for the method and an example to add the sheets to the group. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
add worksheet to group
Outstanding!!
Thanks, Bob!! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
add worksheet to group
Thank you, and it is a pleasure.
-- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) wrote in message ... Outstanding!! Thanks, Bob!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Go to first empty worksheet in a certain group of sheets | Excel Discussion (Misc queries) | |||
how can I group information from more than one worksheet | Excel Worksheet Functions | |||
how to group records in a new worksheet | Excel Worksheet Functions | |||
how to group records in a new worksheet | Excel Discussion (Misc queries) | |||
Group Function on a Protected Worksheet | Excel Programming |