ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Code printing problem (https://www.excelbanter.com/excel-programming/300543-vba-code-printing-problem.html)

Fred_is_stuck

VBA Code printing problem
 
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

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

VBA Code printing problem
 
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

--
Don Guillett
SalesAid Software

"Fred_is_stuck " wrote in
message ...
Hi there hope someone can help me deal to this.

What im trying to achieve is, Send the print job to the print preview
and finally sending the job to the printer if desired and NOT print
blank rows beyond the actual data, keeping in mind all cells are
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 have
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 range
selection and tries to print the entire sheet which is 30 printable
pages. :-(

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

Sub myprint1test()
If MsgBox("Do you want to Print this Document?", vbYesNo, "Report
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 to
fix it but I can't figure it out.

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

Thanks in advance.


---
Message posted from
http://www.ExcelForum.com/





All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com