+ Reply to Thread
Results 1 to 8 of 8

Resizing cell in inches

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2000
    Posts
    31

    Resizing cell in inches

    Hi Everybody,

    I need to redo cell sizes – the width and the height in inches
    While searching, I came across the a macro at http://processtrends.com/pg_charts_cell_size.htm

    As per this line of code, it seems cell width can be set only in number of characters the cell can accommodate.
    Columns(what_col).ColumnWidth = wide_char

    OK. So, with Application.DefaultWebOptions.PixelsPerInch, it is possible to convert the reqd cell width in inches to pix and use the formula
    Say,
    ColumnWidthInPix = ColumnWidthInInches * Application.DefaultWebOptions.PixelsPerInch

    And then define cell width in characters with
    wide_char = (wide_pix - 5) / 5.

    Now the question is
    1. Why this “-5” and the division by 5 while converting from pix to character ? Pixel sizes vary. So why this constant “-5” and division by 5 ?
    2. There seems to some connection with the width of standard font and cell sizes. If so what? How is it possible to find the width of the standard font via VBA ?
    3. Or is there a way to define cell width in inches directly ?

    Thanks in advance,

    Geetha

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Resizing cell in inches

    Hi,

    Does the following help
    http://support.microsoft.com/kb/73591

    Remember 1inch = 96 pixels = 72 points

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Resizing cell in inches

    I think pixels/inch varies by display.

    Perhaps you can adapt this:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    01-23-2009
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2000
    Posts
    31

    Re: Resizing cell in inches

    Hi Richard,
    Thanks for that prompt reply. That link helped me understand better how characters fit into a cell.

    Hi shg,
    That code is great, especially fVsacl & fHSacl And the flexibilty between Cms & Inches. Wonder how long it took you to come up with this. I was not comfortable working with pixels as they vary.
    But i think it needs one correction. In this line ---- fCnv = IIf(sUnits = "inch", 72, 72 / 25.4) ----- there is a typo. For cms, fCnv should be 72 / 2.54. Correct me if I am wrong.

    One more thing, since I am still learning, why is SquareCells a function and not a regular sub ? I thought functions were required when a procedure needs to give out a result, like UDFs. Please, can you explain ?

    I found this too, at http://www.dailydoseofexcel.com/arch...ths-in-points/ . The suggestion that setting column width needs to be done 3times atleast seems to be true.

    Thanks once again and regards to both of you,

    Geetha
    Last edited by Geetha Gupta; 11-27-2010 at 09:15 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Resizing cell in inches

    That code is great, ...
    You're welcome, glad it helped.
    For cms, fCnv should be 72 / 2.54
    The alternative units are mm, not cm
    why is SquareCells a function and not a regular sub
    It returns the actual aspect of the cells.

  6. #6
    Registered User
    Join Date
    01-23-2009
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2000
    Posts
    31

    Re: Resizing cell in inches

    Dear shg,
    I am sorry, I did'nt notice that "mm". For some reason , i assumed it was cm.

    I think your code sets columns and rows 4times. So, rows too need repeated setting, is it ? but since rows are set in points, which is already being done, why do it again and again ?

    The actual aspect of the cells - what does it mean ? And how does a Function procedure do that ? I think I am deviating. So if the answer is short, it is OK. Else i should start a new thread. Please advice.

    Thanks and regards,

    Geetha

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Resizing cell in inches

    The actual aspect of the cells - what does it mean ?
    Here, the ratio of height to width.
    And how does a Function procedure do that ?
    Look at the last line of code.

  8. #8
    Registered User
    Join Date
    01-23-2009
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2000
    Posts
    31

    Re: Resizing cell in inches

    Hi shg,

    Got it.

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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