+ Reply to Thread
Results 1 to 3 of 3

Set each column in a pivot table with a width as long as the longest word in title cell

  1. #1
    Registered User
    Join Date
    07-13-2012
    Location
    Calgary, Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Question Set each column in a pivot table with a width as long as the longest word in title cell

    Hi! This is my first post and I just read the rules so please let me know if I missed any important steps. Thanks and here we go!!

    The following code is in the middle of a large private sub which formats various elements of a pivot table for presentation purposes.
    I am trying to get excel to:
    1. Recognize how big the largest word in the header cell is.
    2. Set the column width to fit that largest word.
    3. Wrap text in that cell.

    This will make my variably-sized table always have the most efficient width.
    Something is wrong in my code. It is simply not setting any column widths.
    Hopefully someone has some ideas.
    Thanks!


    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    07-13-2012
    Location
    Calgary, Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Set each column in a pivot table with a width as long as the longest word in title cel

    Okay I've got it to work 90% by changing to the code below. The problem now is that it is working for 'some' cells and not others.
    The cells it's not working for it is setting the ColumnWidth too small.
    Hopefully someone has a solution. Thanks!!

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-13-2012
    Location
    Calgary, Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Set each column in a pivot table with a width as long as the longest word in title cel

    I have since realized that I need to determine the "Pixel" length of the text string.
    I am not sure how to replace my LEN code above to do that so if there are any suggestions it would be greatly appreciated!

+ 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