vba code needs a little tweak

palaeontology

Active Member
Joined
May 12, 2017
Messages
444
Office Version
  1. 2016
Platform
  1. Windows
I'm currently using the following code (inside a much larger code) to print all worksheets that are named with a 5-digit code ....

Code:
For Each ws In ThisWorkbook.Worksheets    If ws.Name Like "#####" Then
        ws.Range("P22:U22").Font.Color = vbWhite
        ws.Range("P22:U22").Interior.Color = vbWhite
        ws.PageSetup.Orientation = xlLandscape
        ws.PrintOut From:=1, To:=1
    End If
Next ws

The code also forces the prints to be in Landscape.

What would I need to add if I want to force the prints to be ...

* one-sided
* Narrow Margins (Left 0.64cm Right 0.64cm Top 1.91cm Bottom 1.91cm )
* Fit sheet on one Page

I have these print-settings as default on my own computer, but this spreadsheet will be used by about 70 other users who are likely to have different settings to those I know are required.

Kind regards,

Chris
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thanks RedBeard,

I just had a quick look, and it looks brilliant.

Kind regards,

Chris
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

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