vba autofit doesn't work on wrapped text cells

crazydragon84

Board Regular
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
 

Some videos you may like

This Week's Hot Topics

Top