Sub AutoResizeTable() Dim tbl As ListObject Set tbl = ActiveSheet.ListObjects('Table1') '将'Table1'替换为你的表格名称 tbl.TableStyle = 'TableStyleMedium9' '可选,更改表格样式

With tbl.Range
    .HorizontalAlignment = xlCenter '可选,水平居中
    .VerticalAlignment = xlCenter '可选,垂直居中
    .WrapText = True '可选,自动换行
    .Columns.AutoFit '自动调整列宽
    .Rows.AutoFit '自动调整行高
End With

End Sub


原文地址: https://www.cveoy.top/t/topic/mALg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录