+ Reply to Thread
Results 1 to 2 of 2

Adjust the row heigt and column width to fit a certain number of pages

  1. #1
    Registered User
    Join Date
    04-28-2014
    Location
    Danmark
    MS-Off Ver
    Excel 2010
    Posts
    1

    Adjust the row heigt and column width to fit a certain number of pages

    I am trying to make a macro that adjusts the row heigt and column width within the printarea so that they fit a certain number of pages before printing to pdf. The purpose of this macro is to generate the "same" pdf file no matter what computer (with differet resolution, print settings and so on) when printing.

    The printing to pdf works well for me, but the fitting of the columns and rows not so much

    I have realised that the following section adjusts the column width and that the input needed is in excel units:

    Please Login or Register  to view this content.
    In my current setup the column width needs to be 2.14 (excel units). So far so good, now to determine what the width should be on any computer.

    I get the page width in points:

    Please Login or Register  to view this content.
    Subtract the margins and divide by 32 (beeing the number columns that I would like to fit on one page):

    Please Login or Register  to view this content.
    Now I have the column width needed in points so I transform that to excel units by a factor:

    Please Login or Register  to view this content.
    And apply the found width to the columns of interest.

    Please Login or Register  to view this content.
    What I get is a cWid of 2.0601 (excel units) for my setup instead of the needed 2.14. Same procedure is used for the rows (subtracting the header, footer, top and bottom margins from the page height of 11.692 inches) yielding a cHei of 1.841664 instead of 2.14 which is also needed here (50 rows on one page)

    Margins are set to normal in the macro before any of the editing of the column and row width and height.

    Any clue what I am doing wrong? Or if there is a better way to reach the same goal (generating a pdf that looks exatcly the same when printing from different computers)?

    Regards Emil

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Adjust the row heigt and column width to fit a certain number of pages

    Have you tried the FitToPagesWide and FitToPagesTall Properties?

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Finding largest number in a column and adjust column width to fit
    By rob47uk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2014, 07:12 PM
  2. [SOLVED] Run macro and adjust the column width range A:Y
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-03-2014, 12:16 PM
  3. Replies: 3
    Last Post: 08-03-2006, 01:00 PM
  4. [SOLVED] Adjust column width
    By tlee in forum Excel General
    Replies: 2
    Last Post: 05-04-2006, 07:00 PM
  5. Auto Adjust the Width of a Column
    By reddog9069 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 12:10 PM
  6. Adjust Column Width?
    By CDAK in forum Excel General
    Replies: 0
    Last Post: 06-16-2005, 06:05 PM
  7. [SOLVED] adjust column width
    By coolbeans in forum Excel General
    Replies: 1
    Last Post: 05-15-2005, 08:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1