VBA - Page Setup - Fit all columns on one page.

HighAndWilder

Well-known Member
Joined
Nov 4, 2006
Messages
776
Office Version
  1. 365
Platform
  1. Windows
I'd like to fit all columns on one page in page setup using VBA.

How do I do this?

Lots of suggestions as below but this does not work.

Thanks

VBA Code:
With ActiveSheet.PageSetup
      .FitToPagesWide = 1
End With
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try:
VBA Code:
With ActiveSheet.PageSetup
    .Zoom = False
    .FitToPagesWide = 1
End With
Thanks for responding.

I've tried that and it puts all of the data onto a single page.

I need the third option - Fit All Columns On One Page
 

Attachments

  • scaling.png
    scaling.png
    53.1 KB · Views: 4
Upvote 0
I think it might be remembering a previous setting try resetting the Tall parameter at the same time.
(Credit to @MARK858 in an old thread on the Forum)

VBA Code:
With ActiveSheet.PageSetup
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = False
End With
 
Upvote 0
I think it might be remembering a previous setting try resetting the Tall parameter at the same time.
(Credit to @MARK858 in an old thread on the Forum)

VBA Code:
With ActiveSheet.PageSetup
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = False
End With
That works, Thanks.

It would be nice if the wording was similar as it is when the changes are made manually but we can't have everything.

Onto the next challenge.
 
Upvote 0

Forum statistics

Threads
1,225,747
Messages
6,186,792
Members
453,371
Latest member
HMX180

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