print specific tabs

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

hi guys,

is there a way i can put a button within the first sheet of my
workbook that says.. print workbook

when doing so, it will print the following tabs

notes
actual
spend calendar
purchase record

and within this function, look at tabs 001-013 and identify if there
is any value in $J$38 > 0 in each tab, if so, print the tabs that have
a value > 0

cheers
chuck
 
One way:

Option Explicit
Sub testme()

Dim myNames() As String
Dim iCtr As Long
Dim myStr As String

ReDim myNames(1 To 4)
myNames(1) = "Notes"
myNames(2) = "Actual"
myNames(3) = "Spend Calendar"
myNames(4) = "Purchase Record"

For iCtr = 1 To 13
myStr = Format(iCtr, "000")

If Worksheets(myStr).Range("J38").Value > 0 Then
ReDim Preserve myNames(1 To UBound(myNames) + 1)
myNames(UBound(myNames)) = myStr
End If
Next iCtr

If UBound(myNames) = 4 Then
'skip printing???
Else
Worksheets(myNames).PrintOut preview:=True
End If

End Sub

You may not want that check at the end.
 
Back
Top