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

HighAndWilder

Well-known Member
Joined
Nov 4, 2006
Messages
661
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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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: 2
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,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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