Help with joining two macros together

P

pano

Hi, I would like to join these together, but have the second macro
only apply to the sheets
monback,tuesback,wedback,thursback,fridback,satback as they are the
only sheets that may have two pages to print. The print button will be
on a sheet called starta.

Thanks code below....

Sub PrintMontoFrid()
'Print out End Of Week Stats
Application.ScreenUpdating = False
Sheets(Array("monday", "monback", "tuesday", "tuesback",
"wednesday", "wedback", "thursday", "thurback", "friday", "fridback",
"saturday", "satback", "weekly")).Select
ActiveWindow.SelectedSheets.PrintOut copies:=1
Sheets("starta").Select
Application.ScreenUpdating = True
End Sub


Sub Print1or2pages()
If Range("total1") > 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") > 0 Then ActiveSheet.PrintOut From:=2, To:=2
End Sub
 
D

Don Guillett

untested but try

Sub PrintMontoFrid()
'Print out End Of Week Stats
Application.ScreenUpdating = False
myarray=Array("monday", "monback", "tuesday", "tuesback",
"wednesday", "wedback", "thursday", "thurback", "friday", "fridback",
"saturday", "satback", "weekly")
for each w in myarray
w.print
next w
Application.ScreenUpdating = True
End Sub
 
P

pano

Don it errors out but could you explain what each w in my array
means???

This is the error
w.print
runtime error 424 object required


Thanks so far
 
D

Don Guillett

It should have been w.printout but that's not the only problem. I just
tested this
The for each is a looping macro. Look in the vba help index for LOOP and go
from there.
It might be easier to exclude the undesired sheets instead.

Sub PrintMontoFrid()
'Print out End Of Week Stats
Application.ScreenUpdating = False
myarray = Array("monday", "monback", "tuesday", "tuesback", _
"wednesday", "wedback", "thursday", "thurback", "friday", _
"fridback", "saturday", "satback", "weekly")
For Each w In myarray
'MsgBox w
'Sheets(w).PrintPreview
Sheets(w).PrintOut
Next w
Application.ScreenUpdating = True
End Sub
 

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