how do i get a message box asking me if i want to print befor my macro prints?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Guys,

I've got this macro that runs, and part of what it does is print out a document, but I don't always want to print it out.

this is the part of the code that currently prints

Code:
Sheets("Print Page (2)").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1

How do I get it to show a message box saying "Do you want to print a receipt?"
with the option of yes or no, if yes then print and carry on with macro if no skip print and carry on with macro?

Thanks

Tony
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try

Code:
Sheets("Print Page (2)").Select
If MsgBox("Do you want to print a receipt?", vbYesNo + vbQuestion) = vbYes Then ActiveWindow.SelectedSheets.PrintOut Copies:=1
 
Upvote 0
Code:
If MsgBox("Would you like to continue with Printing?", vbOKCancel, ("Print Confirmation")) = vbOK Then
Sheets("Print Page (2)").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
 
Upvote 0
Brilliant,
Thank to both of you, I was miles away so you've been a massive help

Tony
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,272
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top