Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message before Printing specific sheets

Status
Not open for further replies.

Cpreston

MIS
Mar 4, 2015
987
GB
Hi

Two things please

1. I have a macro with the following code which prints specific sheets, this works ok. I would like a message to pop up with a YEs No answer, if No it does not print and stops the action and if Yes continue to print the specific pages.

Sub PrintingPEFC()
Sheets("SawnPivot").PrintOut Copies:=1
Sheets("ArbordeckPivot").PrintOut Copies:=1
Sheets("BespokePivot").PrintOut Copies:=1
Sheets("StockPivot").PrintOut Copies:=1

End Sub

Could someone please advise this can be achieved. I will Google and try some things out in the meantime.

2. Also when testing such things is there a way to print to screen instead of printer to save on paper?

Thanks
 
Its ok managed to solve this on my own, so just ion case someone is having the same issue below is my code. I have preview so it goes to screen and added in vbYesNoCancel instead of yesno but either way would have worked.

Sub PrintingPEFC()
Dim Answer As Integer
Answer = MsgBox("Have you done the Stock Pivot calcualtions?", vbYesNoCancel)
If Answer = vbYes Then
Sheets("SawnPivot").PrintOut Preview:=1
Sheets("ArbordeckPivot").PrintOut Preview:=1
Sheets("BespokePivot").PrintOut Preview:=1
Sheets("StockPivot").PrintOut Preview:=1
Else
'do nothing
End If
End Sub
 
I would shorten it a bit.

Code:
Sub PrintingPEFC()
If [blue]vbYes = MsgBox("Have you done the Stock Pivot calcualtions?", vbYesNoCancel) [/blue]Then
  Sheets("SawnPivot").PrintOut Preview:=1
  Sheets("ArbordeckPivot").PrintOut Preview:=1
  Sheets("BespokePivot").PrintOut Preview:=1
  Sheets("StockPivot").PrintOut Preview:=1
End If
End Sub

Personally, I hate juggling data between variables.



Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Andy, I will not tolerate any "hate" speech here 👺

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Sorry. :-(
Substitute ‘I hate’ with ‘I am opposed to’, ‘I don’t like’, ‘I am against’, or any other PC (or Mac) expression of my dis-like of juggling data.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Well I actually HATE the PC speech "rules!"

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top