LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help! Print Preview Zoom is Grayed Out...Doesn't zoom. PK Excel Discussion (Misc queries) 0 July 20th 09 03:33 PM
ZOOM alex Excel Worksheet Functions 2 February 22nd 08 07:05 PM
Can't Zoom LOUR Charts and Charting in Excel 0 April 19th 07 09:00 PM
zoom dstiefe Excel Programming 1 August 18th 05 10:04 PM
Zoom David Excel Programming 2 October 15th 03 12:53 PM


All times are GMT +1. The time now is 09:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"