请参考以下示例。在记录集中,可以设置该记录集的Range对象,对全部字段(即各列)设置EntireColumn.AutoFit,可实现按该字段的最合适列宽。
With ActiveSheet
    Cells.Select
    With Selection
        .VerticalAlignment = xlCenter    '设置整张表行居中
    End With
    .Cells(2, 5).RowHeight = 22          '设置Row=2,col=5,行高=22
    .Cells(2, 5).EntireRow.AutoFit       '最合适的行高
    .Cells(2, 5).ColumnWidth = 50        '该单元所在列宽=50
    .Cells(2, 5).EntireColumn.AutoFit    '最合适的列宽
End With