Excel - VB code to default to print 1 page

santa12345

Board Regular
Joined
Dec 2, 2020
Messages
70
Office Version
  1. 365
Platform
  1. Windows
Hello.
Hopefully this is simple.
I have a file. text.xls... tab name is sheet1, I want to print just one page.
I want it to default to do this everytime. Can I add VB code to do this?
Seems like anything I do on the print screen, is not saved the next time I open it up.
Thank you.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Have you tried:

VBA Code:
Worksheet.PrintOut From:=1, To:=1, Copies:=1
 
Upvote 0
I will try that.
2 questions.
1. If the file has 10 tabs how would i specify the specific tab to apply those changes to.
2. Also - if i had a label tab and within the label tab has a field calculated out..how many pages of labels to print... let's say in label tab cell A1.. it says 5. can i vb code that to say print pages 1-5 on the labels tab..or this that not possible?
Thanks again.
 
Last edited:
Upvote 0
VBA Code:
Sheets("Sheet1").PrintOut From:=1, To:=1, Copies:=1
 
Upvote 0
VBA Code:
Worksheets("Sheet1").PrintOut From:=1, To:=1, Copies:=1
 
Upvote 0
I will try that.
2 questions.
1. If the file has 10 tabs how would i specify the specific tab to apply those changes to.
2. Also - if i had a label tab and within the label tab has a field calculated out..how many pages of labels to print... let's say in label tab cell A1.. it says 5. can i vb code that to say print pages 1-5 on the labels tab..or this that not possible?
Thanks again.

Maybe try:

VBA Code:
Worksheets("label").PrintOut From:=1, To:=Range("A1").Value, Copies:=1

Or...

VBA Code:
Sheets("label").PrintOut From:=1, To:=Range("A1").Value, Copies:=1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,157
Messages
6,170,419
Members
452,325
Latest member
BlahQz

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