Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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
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 10:24 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"