ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Print depending on tab colour (https://www.excelbanter.com/excel-discussion-misc-queries/150331-print-depending-tab-colour.html)

Saintsman

Print depending on tab colour
 
Is it possible to print only those tabs of a particular colour - say yellow?

Saintsman

Mike H

Print depending on tab colour
 
Try this:-

Sub selectiveprint()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Select
If ActiveSheet.Tab.ColorIndex = 6 Then
wSheet.PrintOut
End If
Next wSheet
End Sub


Mike


"Saintsman" wrote:

Is it possible to print only those tabs of a particular colour - say yellow?

Saintsman


Saintsman

Print depending on tab colour
 
Thanks - all I need to do is group the sheets for page numbering & I'm there

"Mike H" wrote:

Try this:-

Sub selectiveprint()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Select
If ActiveSheet.Tab.ColorIndex = 6 Then
wSheet.PrintOut
End If
Next wSheet
End Sub


Mike


"Saintsman" wrote:

Is it possible to print only those tabs of a particular colour - say yellow?

Saintsman


JLatham

Print depending on tab colour
 
Try this, I think you'll find it does the job for you. It does leave the
sheets with chosen color selected as a group.

Sub GroupSheetsByColorAndPrint()
'change ProperColor to color code you need
'13 is 'standard' yellow in Excel 2007
'6 is Yellow in earlier versions
'
'the array SheetsGroup() will always have
'an empty element as the last element,
'this code takes that into account
'
Const ProperColor = 6
Dim SheetsGroup() As String
Dim WS As Worksheet
ReDim SheetsGroup(1 To 1)
For Each WS In Worksheets
If WS.Tab.ColorIndex = ProperColor Then
SheetsGroup(UBound(SheetsGroup)) = WS.Name
ReDim Preserve SheetsGroup(1 To UBound(SheetsGroup) + 1)
End If
Next
If UBound(SheetsGroup) 1 Then
ReDim Preserve SheetsGroup(1 To UBound(SheetsGroup) - 1)
Sheets(SheetsGroup).Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
End Sub


"Saintsman" wrote:

Thanks - all I need to do is group the sheets for page numbering & I'm there

"Mike H" wrote:

Try this:-

Sub selectiveprint()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Select
If ActiveSheet.Tab.ColorIndex = 6 Then
wSheet.PrintOut
End If
Next wSheet
End Sub


Mike


"Saintsman" wrote:

Is it possible to print only those tabs of a particular colour - say yellow?

Saintsman



All times are GMT +1. The time now is 07:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com