+ Reply to Thread
Results 1 to 8 of 8

Macro to Autofit Those Columns containing Indicator #####

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Macro to Autofit Those Columns containing Indicator #####

    I have tried to write code to autofit only those cols containing ####

    However, these cols are not being autofitted


    It would be appreciated if you someone could kindly amend my code


    Please Login or Register  to view this content.

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

    Re: Macro to Autofit Those Columns containing Indicator #####

    Maybe.

    Please Login or Register  to view this content.
    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.

  3. #3
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Autofit Those Columns containing Indicator #####

    Thanks for your help, but only need those columns that contain the ###### to autofit

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Macro to Autofit Those Columns containing Indicator #####


    Just using Text property rather than Value as the value can't be '#####' !
    To combine with Like operator …

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Macro to Autofit Those Columns containing Indicator #####

    Hi all!
    Howard - the #### is not the cell value, it's just Excel's visual cue that numeric data contained in the cell is too wide to be displayed.
    However, I see that the two columns of interest in the sample both include the word "Date" in the header. Could you use that to ID them?
    Please Login or Register  to view this content.
    Last edited by leelnich; 07-06-2023 at 08:34 AM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try these !


    According to VBA help a header is useless …

    PHP Code: 
    Sub Demo0()
             
    Dim Rc As Range
        
    For Each Rc In Sheet1.UsedRange.Rows(2).Cells
              
    If Rc.Text Like "[#]*[#]" Then Rc.EntireColumn.AutoFit
        Next
    End Sub 

    And the smarter to check columns :

    PHP Code: 
    Sub Demo1()
             
    Dim Rc As Range
        
    For Each Rc In Sheet1.UsedRange.Columns
          
    If Not Rc.Find("#*#", , xlValues1Is Nothing Then Rc.AutoFit
        Next
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 07-06-2023 at 08:35 AM.

  7. #7
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Autofit Those Columns containing Indicator #####

    Thanks for the code Marc

    It works perfectly

  8. #8
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Autofit Those Columns containing Indicator #####

    Thanks for the help Leelnich

    The First Date is the date of the transaction and the second date is the date it was processed

+ 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. [SOLVED] Autofit 3 columns
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2023, 04:06 AM
  2. Why won't columns autofit?
    By Curious Dude in forum Excel General
    Replies: 1
    Last Post: 04-12-2019, 10:56 AM
  3. [SOLVED] Need Formula to Place Indicator After Comparing Two Columns
    By JSpree in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2017, 08:38 PM
  4. [SOLVED] Can I determine the effect of autofit to .columnwidth prior to executing the autofit?
    By kadeo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-13-2016, 10:29 AM
  5. AutoFit columns with macro
    By deano3141 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2014, 08:58 AM
  6. Autofit all columns
    By cultavix in forum Excel General
    Replies: 2
    Last Post: 11-25-2008, 07:26 AM
  7. Autofit some columns
    By Me in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2005, 05:06 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