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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,226,730
Messages
6,192,699
Members
453,747
Latest member
tylerhyatt04

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