Hi
I have a workbookk with 6 to 40 worksheets in it.
I want to select all sheets that meet a certain condition and print them as a group. (Unknown number of sheets)
I can find examples where the sequance of sheets in the file is known, but not if they are random. The sheets can be in a random order. There could be from 1 to 20 sheets selected to the group.
My code snippet is below. It only is selecting the last worksheet that meets the condition, the grouping of the sheets is not working.
****************************************
For Each vPrintSht In ActiveWorkbook.Worksheets
If Right(vPrintSht.Name, 6) = Left(vGenAlias, 6) Then
Sheets(vPrintSht.Name).Select True
vPrintInclude = vPrintSht.Name
Else
Sheets(vPrintSht.Name).Select False
End If
Next
Sheets(vPrintInclude).Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
*********************************************
Any thoughts?
I have a workbookk with 6 to 40 worksheets in it.
I want to select all sheets that meet a certain condition and print them as a group. (Unknown number of sheets)
I can find examples where the sequance of sheets in the file is known, but not if they are random. The sheets can be in a random order. There could be from 1 to 20 sheets selected to the group.
My code snippet is below. It only is selecting the last worksheet that meets the condition, the grouping of the sheets is not working.
****************************************
For Each vPrintSht In ActiveWorkbook.Worksheets
If Right(vPrintSht.Name, 6) = Left(vGenAlias, 6) Then
Sheets(vPrintSht.Name).Select True
vPrintInclude = vPrintSht.Name
Else
Sheets(vPrintSht.Name).Select False
End If
Next
Sheets(vPrintInclude).Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
*********************************************
Any thoughts?