VBA Code printing problem

  • Thread starter Thread starter Fred_is_stuck
  • Start date Start date
F

Fred_is_stuck

Hi there hope someone can help me deal to this.

What im trying to achieve is, Send the print job to the print previe
and finally sending the job to the printer if desired and NOT prin
blank rows beyond the actual data, keeping in mind all cells ar
populated with formula linked to sheet1. this dataset has 2 pages.
there are 15 datasets on the sheet.

this is the formula that I am using to print page one of two, I hav
another macro to print page 2 if I see it is occupied by data.

**********

this is the code that works as per last sentence.

Sub print1()
Application.ScreenUpdating = False
Sheets("Psheet").Select
Range("A1:U60").Select
ActiveWindow.SelectedSheets.PrintPreview
Selection.PrintOut Copies:=1, Collate:=True
Sheets("sheet1").Select
Range("D7").Select
Application.ScreenUpdating = True
End Sub

*************

this is the code that gives me the yes no criteria but drops the rang
selection and tries to print the entire sheet which is 30 printabl
pages. :-(

*************

Sub myprint1test()
If MsgBox("Do you want to Print this Document?", vbYesNo, "Repor
Preview and Print Check") = vbNo Then Exit Sub
Application.ScreenUpdating = False
Sheets("Print1test").Select
Range("A1:U60").Select
ActiveWindow.SelectedSheets.PrintPreview
Selection.PrintOut Copies:=1, Collate:=True
Sheets("sheet1").Select
Range("D7").Select
Application.ScreenUpdating = True
MsgBox "Your Report is now Printing"
End Sub

Hope someone can end my misery. I know it must be a simple solution t
fix it but I can't figure it out.

Im hoping to use this fix in a another spreadsheet which is about 50
rows long.

Thanks in advance
 
If you use printpreview it must be cleared with the c key or print key. Try
this. You do NOT have to first select the sheet or range to print. This will
work on your sheet from anywhere such as your sheet1.

Sub printpreviewit()
With Sheets("sheet11").Range("b6:b16")
..PrintPreview
'if you use preview you must touch c key to clear before continuing
ans = InputBox("Do you want to print, Enter Y for Yes or N for NO")
If UCase(ans) = "Y" Then .PrintOut
End With
End Sub
 
Hey there Don,

Thanks for the code it's cleaner than mine :)

just to push my luck :) do you know if it is possible to get a macro t
only print values on a 2 sheet selection? I have 2 sheets with formul
linked to the data entry sheet, and in the early stages of the mont
only the first sheet will be populated with values, and I would rathe
not print the blank sheet :) the way I have it all setup at the momen
is 2 macros to print macro 1 for page 1 Macro 2 for page 2.

thanks for helping :)

************************


If you use printpreview it must be cleared with the c key or print key
Try
this. You do NOT have to first select the sheet or range to print. Thi
will
work on your sheet from anywhere such as your sheet1.

Sub printpreviewit()
With Sheets("sheet11").Range("b6:b16")
..PrintPreview
'if you use preview you must touch c key to clear before continuing
ans = InputBox("Do you want to print, Enter Y for Yes or N for NO")
If UCase(ans) = "Y" Then .PrintOut
End With
End Sub
 
Why not an if day(today())< whateverday then print this range else print
that range.
 

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

Back
Top