Unique print macro question

G

Guest

Excel 2003 -

Workbook has many sheets - all but three are hidden.

"shtInput" is always visible

What I want to do is to control which sheet get printed first and I want the
sheet that has a sheet name ending in "v" print first and the other sheet to
print second. There will always be only one visible sheet that has a sheet
name ending if "v".

Below is the working macro that I would like to add to. Any help would be
greatly appreciated.




Sub Print_pages()
Dim sht As Worksheet
shtAgent.Visible = False
For Each sht In Worksheets
If sht.Name <> shtInput.Name And sht.Visible = True Then
sht.PrintOut
End If
Next
End Sub
 
G

Guest

Okay I got this far

Sub Print_pages()
Dim sht As Worksheet
Dim page1 As String
Dim page2 As String
shtAgent.Visible = False
For Each sht In Worksheets
If sht.Name <> shtInput.Name And sht.Visible = True Then
If (Right(sht.CodeName, 1) = "V") Then
page1 = sht.Name
Else
page2 = sht.Name
' sht.PrintOut
End If
End If
Next
' page1.PrintOut
' page2.PrintOut
End Sub

But how do I tell it to print out page1 and page2? Get an error message
with page1.printout
 
G

Guest

Got it

Replace the last two lines with
worksheet(page1).printout
worksheet(page2).printout
 
G

Guest

try
For Each sht In Worksheets
If sht.Name <> shtInput.Name And sht.Visible = True Then
If (Right(sht.CodeName, 1) = "V") Then sht.printout
end if
next
For Each sht In Worksheets
If sht.Name <> shtInput.Name And sht.Visible = True Then
If (Right(sht.CodeName, 1) <> "V") Then sht.printout
end if
next







:
 

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