vba autofit doesn't work on wrapped text cells

crazydragon84

Board Regular
Joined
Feb 19, 2015
Messages
195
Hi I have a sheet that has variable amount of text in column A. The text is fairly long, it's a paragraph. These cells are wrapped text. The issue is when i do an autofit (either via VBA or even when i do it manually), the autofit works for few of the cells but some will have extra space at the end. when i either make the column width much wider or narrower, the auto fit seems to work, but not at the width i'm trying to keep those cells at. I've tried specifying the range or looping through each row to do autofit one by one, but all of these solutions give me the same issue. Any feedback would be appreciated. Thank you for your help!

Code:
With Sheets("ABC")    With .Columns("A:A")
        With .Font
            .Name = "Cambria"
            .Color = RGB(12, 35, 64)
            .Size = 12
        End With
        .ColumnWidth = 96
        .HorizontalAlignment = xlJustify
        .VerticalAlignment = xlTop
        .WrapText = True
    End With
    
    .Cells.EntireRow.AutoFit
    
End With
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,213,496
Messages
6,113,995
Members
448,539
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top