+ Reply to Thread
Results 1 to 32 of 32

Set column width by centimeter

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Set column width by centimeter

    Hello everyone
    I have the following code the change the column width to be by centimeter instead of points
    Please Login or Register  to view this content.
    I tested the code >> selected B4 cell >> put 5 in the input box
    I navigated to view tab then Page layout
    Right click on column B >> I found the width is 5.21cm ???!!
    How to get exactly the width in centimeter??
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Set column width by centimeter

    http://www.excelhowto.com/how-to-set...in-cm-at-once/
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    Thanks for the link .. But it doesn't solve the problem
    Even if I edit the column width manually in page layout view and then test the column width again I find it not exactly
    For example : Be in page layout view >> right click column B >> Column width >> Put 3cm >> test the column width again you would find it 2.99 ..!!
    That's weird or it is a matter of points and centimeters

    Thanks for reply

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

    Re: Set column width by centimeter

    You can't set column widths precisely. The smaller you make the font size for style Normal, though, the more accurate you can get.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    Thanks for reply
    I have applied the smallest font size of style normal .. and still have the same problem
    I need VBA code that achieve that task .. just to adjust column width by centimeters and after that if I checked it (I don't desire to see different results)

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

    Re: Set column width by centimeter

    Maybe you can adapt this:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    Great ... Thanks a lot for sharing it
    Does this function deal with inches only ? How can be edited to deal with the centimeter?
    Sorry for disturbing you

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

    Re: Set column width by centimeter

    Yasser, if you've written any of the code that you've posted lately, I am confident you can manage to convert from inches to centimeters.

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    In fact it is not my code ...I just was trying to search to find a solution to the problem ...
    I think it is a matter of conversion between units (but I'm not expert at this conversion at all)

  10. #10
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Set column width by centimeter

    Inches to cm

    cm = inches/0.39370
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    Thanks a lot Mr. Bruce for sharing
    I tried to change to this line
    Please Login or Register  to view this content.
    But nothing changed when testing the code
    Thanks for reply

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    I tried to change again (converting cm to points)
    Please Login or Register  to view this content.
    I tested it by putting 5 in the inputbox and After testing I found the row height is 5cm (It's ok) but the column width was 5.11 cm) ...

  13. #13
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Set column width by centimeter

    If you want fdim to be in points and there are 72 points to an inch and you are inputting centimeters I would think it would be.
    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    I tested that change also and still the same .. Row height is 5 cm while column width is 5.11cm

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

    Re: Set column width by centimeter

    I retract what I said about Normal's font size affecting affecting the resolution with which you can set column width. On my laptop, the step size is always 0.6 points. That may be affected by monitor resolution or other factors.

  16. #16
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Set column width by centimeter

    Perhaps something like
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Set column width by centimeter

    @mikerikson: its perfect for 5cm but if you enter 10 it becomes 11
    The problem is the way Excel calculates the dimensions
    The width is the number of characters based upon Arial 10.

    This article I found http://excelsemipro.com/2010/10/colu...xcel-versions/
    explains it but does not actually solve it.

    You would have to create a relational formula
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  18. #18
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Set column width by centimeter

    That code assumes that ColumnWidths is linear, i.e. a cell with .ColumnWidth = 3.2 is 3.2 times wider than a cell with .ColumnWidth = 1

  19. #19
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Set column width by centimeter

    Is this gives a better result ?

    Please Login or Register  to view this content.

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Set column width by centimeter

    @karedog: yous result is 5.25 cm and if you enter 10 the the result is 10.5 so there is 2.5 mm increment met 5 cm >
    If I read all that's said about this it isn't easy.
    I've given up but ... who knows, somebody might find the correct formula so that the OP is helped
    Last edited by Keebellah; 10-22-2015 at 04:30 AM. Reason: Type-Oooo

  21. #21
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Set column width by centimeter

    Ok, second try :

    Please Login or Register  to view this content.

  22. #22
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Set column width by centimeter

    Real close:
    5cm = 5cm
    10cm = 10.1cm
    15 = 15.2cm
    This will go up the wider you get but I don't think the OP is looking for that.

    Maybe the OP's drawing a floor plan

  23. #23
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Set column width by centimeter

    I'm thinking that if a difference of .2 cm is a problem, then Excel is being used as something other than a spreadsheet and that other platforms would be better for the purpose intended.

  24. #24
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Set column width by centimeter

    That's what I meant with the the OP was probably using Excel for a floor plan
    I agree 200%

  25. #25
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Set column width by centimeter

    Hmmm. The ruler that is used to verify that the column widths are .2 off can also be used as a drafting tool.

    (I know, "20th century thinking")

  26. #26
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    Thanks a lot everybody for all these ideas and solutions provided...
    I tested Mr. mikerickson's code >> I entered 5cm and got 4.89 / tested 10cm and got 10cm
    As for Mr. Karedog's code .. it took some time and when entered 5 cm I got 5.11
    and the UDF function provided : 5cm I got 5.5cm ** 10 cm I got 11.09 ** 15 cm I got 16.64

    It seems that it is complicated issue
    I have done some search and expect it is concerned screen resolution and if we could deal with pixels and points according to API declarations ,there might be a solution
    Thanks a lot for everyone who is sharing the issue

  27. #27
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Set column width by centimeter

    I'm thinking that the .1 or .11 difference is unavoidable.

    I'm not sure if the results are being measured on a screen or on a print-out, but it wouldn't surprise me if that 1 mm is within the variation between manufacturers for this kind of application.

  28. #28
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    Hope to find solution for this issue
    I think if we could calculate pixels through screen resolution and convert pixels to points or centimeters this may help

  29. #29
    Registered User
    Join Date
    03-30-2014
    Location
    Pittsburgh,PA
    MS-Off Ver
    Office 2010, Home Student 2013
    Posts
    62

    Re: Set column width by centimeter

    Trying to set fixed sizes in Excel can be frustrating. Row height is measured in pixels and points, nominally 1/72nd of an inch. Column width is set in pixels or by the number of zeros of the default font, often 8.43 zeros. Charts and other objects are measured in inches. At least, it's inches here in the United States.

    This gets complicated even more by video driver capabilities, monitors where pixel resolution isn't square, and the worksheet magnification the user selects.

    A 2004 blog post on Daily Dose of Excel suggests that setting column width may have to be done two or three times in a row for the column width to "stick" and become close to accurate.

    http://dailydoseofexcel.com/archives...ths-in-points/

    I think if one wants dimensions to be set accurately, one would have to translate the spreadsheet into a typesetting or CAD program. Even with that, dimensions would only be accurate for print, not for screen display.
    Last edited by thisoldman; 10-23-2015 at 04:28 AM. Reason: Edited to correct typos

  30. #30
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Set column width by centimeter

    You must also keep in mind that when you print it you cannot choose anything like fit to page etc because then the results on paper will be % of the actual size
    Good luck

  31. #31
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Set column width by centimeter

    My last attempt (a dirty one) :

    Please Login or Register  to view this content.
    Bye Bye.gif

  32. #32
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Set column width by centimeter

    Thanks a lot Mr. Karedog
    I tested the code...
    Selected A1 >> Run the macro "Test"
    The result:
    No changes in columns widths
    Some values were in range("A1:A8")
    c
    1
    c
    2
    c
    5
    c
    10

    Any idea>>

+ 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. Reconciling units: Column width and image width
    By MarmaladeLover in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2015, 03:03 PM
  2. 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
  3. Replies: 2
    Last Post: 07-30-2014, 11:13 AM
  4. [SOLVED] Merged Cell column width vs single cell column width
    By ratdogexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2014, 12:23 AM
  5. [SOLVED] Setting individual column width sizes for multi column listbox with VB2011 Mac not working
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 2
    Last Post: 01-26-2014, 06:19 PM
  6. Column Width vs. Text Width
    By jlt199 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2013, 11:45 AM
  7. Set Column Width Based On Total Width Of Other Columns
    By rayneraingoaway in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2006, 06:10 PM

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