VBA to print pages.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Good Day,
Is it possible to print selected ranges on the worksheet base on cell amount?
If K1 value is 5, when click the button automatically will print 5 pages.
Thanks.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Maybe:
VBA Code:
Public Sub Print_K1_Pages()

    With ActiveSheet
        .PrintOut From:=1, To:=.Range("K1").Value
    End With

End Sub
 
Upvote 0
Solution
Hello John,
In regards the code you've been provided , I have two questions..
1) If print button on another worksheet what will be adding to run the code?
2) If K1 value is 4 printing pages coming out tot of 8 psc. (1with print anotherone is blank)

Many Thanks
 
Upvote 0
1) If print button on another worksheet what will be adding to run the code?

VBA Code:
Public Sub Print_K1_Pages()

    With ThisWorkbook.Worksheets("Name of sheet to print")
        .PrintOut From:=1, To:=.Range("K1").Value
    End With

End Sub

2) If K1 value is 4 printing pages coming out tot of 8 psc. (1with print anotherone is blank)

Check the sheet's Margins and Print Area in Print Setup.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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