print specific tabs

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
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top