Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Zoom to fit Columns
Hello All,
I want to set Zoom so that all columns can fit in one page. First, I sum the widths of the visible columns on the page between A and O and convert the measurement to inches. I then set the Orientation, PaperSize and Zoom based on the measurement. I am using the following code-: Dim cw As Double Dim Counter As Long For Counter = 1 To 15 If Sheets("Application").Columns(Counter).EntireColum n.Hidden = False Then cw = cw + Sheets("Application").Columns(Counter).Width End If Next Counter cw = cw / 72 If cw 0 And cw <= 8 Then Sheets("Application").PageSetup.Orientation = xlPortrait Sheets("Application").PageSetup.PaperSize = xlPaperLetter Sheets("Application").PageSetup.Zoom = WorksheetFunction.RoundDown(700 / cw, 0) Else If cw 8 And cw <= 11 Then Sheets("Application").PageSetup.Orientation = xlLandscape Sheets("Application").PageSetup.PaperSize = xlPaperLetter Sheets("Application").PageSetup.Zoom = WorksheetFunction.RoundDown(1000 / cw, 0) Else If cw 11 Then Sheets("Application").PageSetup.Orientation = xlLandscape Sheets("Application").PageSetup.PaperSize = xlPaperLegal Sheets("Application").PageSetup.Zoom = WorksheetFunction.RoundDown(1300 / cw, 0) End If End If End If If my calculations are correct, this code should work fine, but I have been encountering problems. When cw = 14.76 inches, for example, the zoom is 88%, but this zoom results in the last column being printed in a spearate sheet. Theoretically, this Zoom should work since 88% of 14.76 is 13, so all the columns should fit fine on a legal-sized, landscape-oriented page, but maybe I am not understanding clearly how Zoom works. I should note that the left and right margins have been set to zero. What am I doing wrong here? I appreciate any effort to help me. Thank you for your time and consideration. Sincerely, Sisilla |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Zoom to fit Columns
Can you not choose File/Page Setup/Page, click the Fit to: radio button
and enter 1 in the "column wide" input box? Programmatically, that's With Sheets("Application").PageSetup .Orientation = Iif(cw <= 8, xlPortrait, xlLandscape) .PaperSize = Iif(cw <= 11, xlPaperLetter, xlPaperLegal) .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = False End With In article . com, Sisilla wrote: I want to set Zoom so that all columns can fit in one page. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Zoom to fit Columns
On Oct 19, 11:18 am, JE McGimpsey wrote:
Can you not choose File/Page Setup/Page, click the Fit to: radio button and enter 1 in the "column wide" input box? Programmatically, that's With Sheets("Application").PageSetup .Orientation = Iif(cw <= 8, xlPortrait, xlLandscape) .PaperSize = Iif(cw <= 11, xlPaperLetter, xlPaperLegal) .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = False End With In article . com, Sisilla wrote: I want to set Zoom so that all columns can fit in one page.- Hide quoted text - - Show quoted text - ROTFLMAO Are you kidding me, JE? Is it really that simple? I can't believe it! I am blushing over here thinking of how stupid I am. Thanks for the tip! I greatly appreciate it. -Sisilla |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Zoom to fit Columns
That's cool, CLR. I'm glad to hear that my code wasn't completely
useless! :-) Cheers, Sisilla |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Please help! Print Preview Zoom is Grayed Out...Doesn't zoom. | Excel Discussion (Misc queries) | |||
ZOOM | Excel Worksheet Functions | |||
Can't Zoom | Charts and Charting in Excel | |||
zoom | Excel Programming | |||
Zoom | Excel Programming |