+ Reply to Thread
Results 1 to 14 of 14

Autofit to fully display header in a filtered column

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Autofit to fully display header in a filtered column

    This has been bugging me for years, and I want to know if there's a fix:

    I have hundreds of columns, each with a colomn header name. Autofilter is applied. After refreshing the data, I want to autofit the columns, but autofit sometimes obscures the headers. See the attached picture for an example. Column C title is "Recd By BA", and column J title is "PAC". How do I autofit and get the full name of the column to display?

    Any help is appreciated. I'm not averse to using a VBA solution if necessary, but it seems to me this is something Excel should be able to do natively.
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: Autofit to fully display header in a filtered column

    After you have the filters in there, have you tried clicking on the arrow in the top left corner to select the whole sheet. Then you can place your mouse between A and B and then double click. In your example it made both columns just wide enough to see the labels at the top even with the filters on.
    Some people volunteer in soup kitchens or hospitals. I choose to make the world better by trying to help you with Excel. We're all learning.

    <---Click * Add Reputation for all helpful comments. It's like giving a smile.
    Forum Rules: How to mark your post [Solved] and have a happier, Excel enriched life.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Autofit to fully display header in a filtered column

    Yes, that's normally the way I do my manual autofit. The example I posted is merely one example; this happens to me quite often, which is why I'm finally annoyed enought to post about it. The only way I've found to achieve the results I need is to alter the problem Headers by adding 3 or 4 spaces at the end. Then when I apply the autofilter my whole true heading shows. But that's an exhausting workaround when there are hundreds of columns.

  4. #4
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Autofit to fully display header in a filtered column

    I don't see what the problem is. Click on the triangle just above the row numbers and to the left of the column letters like negelbloomy said. That selects the whole worksheet then double click on any column divider in the column header row. All columns in the worksheet will be properly fit to the contents. 3 clicks is all that is.

    Alternatively, with the worksheet selected, click on Format, AutoFit Column Width.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Autofit to fully display header in a filtered column

    My example is attached. As per instructions I've clicked on the triangle just above the row numbers and to the left of the column letters (aka the arrow in the top left corner), which selected the whole sheet. I then double clicked on the column divider between B and C, which autofit all of my columns. AFTER the autofiting, results are as in the attachment, and as stated in my original post. Note columns C and J, which still persist as displaying with part of the header hidden.
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Autofit to fully display header in a filtered column

    There is something in the formatting of those columns that is preventing the proper column widths to be applied. I selected the whole worksheet the clicked on Clear, Formats then re-applied the filters and selected the whole worksheet, all columns properly widened to accommodate the filter buttons showing the complete titles of the columns.

    I confirmed that by downloading your file again and selecting columns C and J, removed the formatting and then selected the whole worksheet and double clicked between a randomly selected pair of columns and all column widths changed to accommodate the column headers with filter buttons.

  7. #7
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: Autofit to fully display header in a filtered column

    If you left format the column headers it will work as well. They seem to be stuck on right formatting right now which forces them to be partially hidden when the filters are added.

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Autofit to fully display header in a filtered column

    @nigelbloomy
    Good observation...remove the right formatting and all is well with the world.

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Autofit to fully display header in a filtered column

    Thanks for the insight. Okay, so now I can understand why it's behaving that way: having them center-aligned is what's messing up those columns. So, if I align left those work fine. That's well and good for a limited number of columns. However many of the workbooks I work with have tons of columns. If I left align the headers to get the titles to show properly for my problem columns, if I have columns containing long strings of data, my headers are going to be way to the left side, instead of centered over my data.

    I want both options: I want my headings centered, so for wide columns the headings are easily associated with the data, and I want the header rows to display fully without having to do a special left alignment for them.

    Any solution ideas?

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Autofit to fully display header in a filtered column

    Select the Whole worksheet, click on the Center align button. All will be centred and the when you double click between any two column dividers in the column header row all columns are widened correctly. Just eliminate the right alignment and you should be ok... I tested this by creating a ridiculously long column title and it worked perfectly with Centre alignment.

  11. #11
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Autofit to fully display header in a filtered column

    Okay, this is weird: I decided to try my own solution, by inserting 3 spaces after each header, using my Cells_Append macro (code is below). I then centered the headers, and autofitted. They all fit beautifully. Then I decided to undo it by using my Cells_Clean macro (code is below). After cleaning, and after Autofitting again, leaving the headers centered, J and C STILL showed correctly. I verified that there were no longer any spaces after them. I then Left aligned column J, and autofitted, and the column shrank in size. I then recentered J, and autofitted again, and the column increased in width to fully display the header. So, why is the autofit procedure working now, when no real change has been done to the cells?
    Please Login or Register  to view this content.

  12. #12
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Autofit to fully display header in a filtered column

    As I see it, the problem columns were right aligned as spotted by nigelbloomy. Once that right alignment is taken care of, the problem no longer exists. I feel that you may be "over-thinking" this.

  13. #13
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Autofit to fully display header in a filtered column

    You're probably right. Seems like center alignment should work in all cases. Thanks so much for all the help.

  14. #14
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Autofit to fully display header in a filtered column

    Thank you for the feedback. It just goes to show that if one tries long enough, a solution will become apparent

+ 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. Replies: 7
    Last Post: 07-25-2014, 05:08 PM
  2. export filtered data (including header row) to new workbook, maintain column width
    By ovetcobo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2013, 03:47 PM
  3. [SOLVED] Copy a specific column data of filtered output without header
    By uvaidya in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-05-2012, 09:21 AM
  4. Display first result from filtered column
    By kdrysdale in forum Excel General
    Replies: 8
    Last Post: 05-12-2009, 11:01 AM
  5. Row / Column Header not fully shown in Normal View
    By codepin in forum Excel General
    Replies: 2
    Last Post: 03-11-2009, 01:22 AM

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