Thread: Printing VBA
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Driscol[_2_] Mark Driscol[_2_] is offline
external usenet poster
 
Posts: 75
Default Printing VBA

You would have to identify your Task pages somehow. Here are two
methods.

1. Hardcode (which may not be desirable) the worksheet names into a
macro.

Option Explicit

Sub PrintTaskSheets()

Dim var As Variant
Dim varArray As Variant

varArray = Array("SheetName3", "SheetName7", "SheetName9")
For Each var In varArray
ActiveWorkbook.Sheets(var).PrintOut
Next var

End Sub


2. Change the color of the Task sheets to anything but white. Print
any sheet with a non-white tab color.

Option Explicit

Sub PrintTaskSheets()

Dim sh As Variant

For Each sh In ActiveWorkbook.Sheets
If sh.Tab.ColorIndex < xlNone Then sh.PrintOut
Next sh

End Sub


Mark



Valery2105 wrote:
Hi,

I have searched hi and low for an answer and hoping that soemone can help me.

I have an Excel workbook that will protected so that no changes may be made
to it with the exception of myself and 2 others. The workbook needs a print
button that will only print of Task pages (ie page 3, 5 ,7) if there is data
in it other than the format contents. Is this possible? Is this a VBA code I
need? Please
help.

Thanks