Excel - VB code to default to print 1 page

santa12345

Board Regular
Joined
Dec 2, 2020
Messages
53
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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
1,295
Office Version
  1. 2013
  2. 2007
Platform
  1. Windows
Have you tried:

VBA Code:
Worksheet.PrintOut From:=1, To:=1, Copies:=1
 

santa12345

Board Regular
Joined
Dec 2, 2020
Messages
53
Office Version
  1. 365
Platform
  1. Windows
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:

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
1,295
Office Version
  1. 2013
  2. 2007
Platform
  1. Windows
VBA Code:
Sheets("Sheet1").PrintOut From:=1, To:=1, Copies:=1
 

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
1,295
Office Version
  1. 2013
  2. 2007
Platform
  1. Windows

ADVERTISEMENT

VBA Code:
Worksheets("Sheet1").PrintOut From:=1, To:=1, Copies:=1
 

johnnyL

Well-known Member
Joined
Nov 7, 2011
Messages
1,295
Office Version
  1. 2013
  2. 2007
Platform
  1. Windows
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:

Forum statistics

Threads
1,140,999
Messages
5,703,639
Members
421,307
Latest member
morrden86

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
Top