+ Reply to Thread
Results 1 to 8 of 8

Changing Table Cell Width

  1. #1
    Registered User
    Join Date
    01-29-2017
    Location
    Saint Petersburg, Russia
    MS-Off Ver
    2021
    Posts
    16

    Changing Table Cell Width

    This simple script:
    Please Login or Register  to view this content.
    ? does not work ? the table is created, but after then the following error occurs in width changing line:

    Run-time error '4608'
    Value out of range
    Please let me know how I can change cells width (it will be different for different cells).

    Thank you!

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Changing Table Cell Width

    Your code works (for me anyway) if you increase the value of your cellWidth variable to anything 3.9 or above.

    BSB

  3. #3
    Registered User
    Join Date
    01-29-2017
    Location
    Saint Petersburg, Russia
    MS-Off Ver
    2021
    Posts
    16

    Re: Changing Table Cell Width

    But I can easily set cell width to 0.35 cm and even less, manually in the table that the script creates, later. Why is that I can’t do it in the script, I can not understand.

    The whole point of the script is to set cell width programmatically, since there will be a lot of cells in the table 😀.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Changing Table Cell Width

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    01-29-2017
    Location
    Saint Petersburg, Russia
    MS-Off Ver
    2021
    Posts
    16

    Re: Changing Table Cell Width

    I have then attached a word file with this macro to the post.

    I thought it would be easier just to copy the code from the start topic into Visual Basic Editor.

    Sample.docm

  6. #6
    Registered User
    Join Date
    01-29-2017
    Location
    Saint Petersburg, Russia
    MS-Off Ver
    2021
    Posts
    16

    Re: Changing Table Cell Width

    Quote Originally Posted by BadlySpelledBuoy View Post
    Your code works (for me anyway) if you increase the value of your cellWidth variable to anything 3.9 or above.
    For me neither 3.9 nor 4.35 work as well.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Changing Table Cell Width

    Here's something to play with.

    Everything works until v3. The first cell fails, the rest are ok. Presumably 0.4 is the lowest limit.

    Same scenario with v4. The first row fails, the rest are ok. Same conclusion.

    Please Login or Register  to view this content.
    Output:
    PHP Code: 
     1.1 
     1.2 
     1.3 
     1.4 
     1.5 
     2.1 
     2.2 
     2.3 
     2.4 
     2.5 
     3.1 
     3.2 
     3.3 
     3.4 
     3.5 
     0.55 
     0.6 
     0.65 
     0.7 
     0.75 
     1.05 
     1.1 
     1.15 
     1.2 
     1.25 
     1.55 
     1.6 
     1.65 
     1.7 
     1.75 
     0.366666666666667 
    0.366666666666667 failed
     0.4 
     0.433333333333333 
     0.466666666666667 
     0.5 
     0.7 
     0.733333333333333 
     0.766666666666667 
     0.8 
     0.833333333333333 
     1.03333333333333 
     1.06666666666667 
     1.1 
     1.13333333333333 
     1.16666666666667 

     0.275 
    0.275 failed
     0.3 
    0.3 failed
     0.325 
    0.325 failed
     0.35 
    0.35 failed
     0.375 
    0.375 failed
     0.525 
     0.55 
     0.575 
     0.6 
     0.625 
     0.775 
     0.8 
     0.825 
     0.85 
     0.875 
    Last edited by TMS; 08-06-2023 at 08:21 PM.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Changing Table Cell Width

    You might need to change the left and right margins from the defaults. The Cell Margins button is in the Alignment group on the Layout tab, I think (can't check at the moment).

+ 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. How to change width of the whole table when changing column width?
    By DVS75 in forum Word Formatting & General
    Replies: 3
    Last Post: 10-01-2022, 07:37 AM
  2. [SOLVED] Convert range to table without changing column width / formatting
    By mastertonn in forum Excel General
    Replies: 17
    Last Post: 05-04-2022, 06:32 AM
  3. [SOLVED] vba changing a column width based on cell content
    By Chanty in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-13-2021, 04:21 AM
  4. Changing the width of a cell with a formula
    By ricku425 in forum Excel General
    Replies: 4
    Last Post: 07-08-2009, 04:21 PM
  5. Changing the width of ONE cell?
    By mwakissey in forum Excel General
    Replies: 2
    Last Post: 05-30-2007, 10:23 PM
  6. [SOLVED] Stop column width from changing on pivot table....?
    By myk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2006, 12:45 PM
  7. Replies: 3
    Last Post: 02-07-2006, 07: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