+ Reply to Thread
Results 1 to 3 of 3

Auto width columns under all circumstances

  1. #1
    Registered User
    Join Date
    01-15-2012
    Location
    Noneofyourbusiness, CO
    MS-Off Ver
    Excel 2007
    Posts
    34

    Auto width columns under all circumstances

    Hello!

    I'm trying to find a way to auto size column widths under all circumstances. The current method I'm using is:

    Right-click worksheet tab --> View Code --> Paste:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Target.EntireColumn.AutoFit
    End Sub


    This works wonderfully for the column I'm entering data in, but I have cells in other columns that reference data in the column I'm entering numbers into and it doesn't resize.

    For example. I'm entering numbers into columns A through Y. In row 100 i've got sum formulas for all of the columns. In row Z I have a cell that takes the SUM of all of the sums in other rows. When I enter numbers into column A only column A adjusts it's size - not Z.

    Is there a solution for this? Thank you so much!

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Auto width columns under all circumstances

    Hi try this
    Please Login or Register  to view this content.
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    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: Auto width columns under all circumstances

    Hi,

    Are you saying that you want all columns resized to accomodate the maximum width in each of the columns? You're using the 'target' in the Worksheet change event which of course will only resize the column containing the cell.

    You could try

    Range("A1:Z1").EntireColumn.Autofit

    instead.

    Incidentally your location is some of our business. It's often very useful when we need to understand your likely system locale settings for say date arithmetic. e.g. US formats are quite different to UK formats.
    Please change it to something meaningful.
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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