VBA Print Page Range

tycasey17

Board Regular
Joined
Sep 26, 2013
Messages
93
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I have a 75-page spreadsheet that I want to be able to print a page or a range of pages without having to specify the normal way. Is there a way to be able to have a dialog box or have a cell dictate which page(s) I need to be printed?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
VBA Code:
Sub PaagesPrint()
Dim PagesPrint As Variant
Dim FrmPage As Long
Dim ToPage As Long
    PagesPrint = InputBox("Type such as 1-2")
    
    FrmPage = Split(PagesPrint, "-")(0)
    ToPage = Split(PagesPrint, "-")(1)
    ActiveSheet.PrintOut From:=FrmPage, To:=ToPage
End Sub
 
Upvote 0
Solution
I appreciate your assistance. I also for got to preface my question. I want to run this code on one sheet while it actually prints from a different sheet, if that makes sense?
 
Upvote 0

Forum statistics

Threads
1,215,632
Messages
6,125,913
Members
449,274
Latest member
mrcsbenson

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