Excel VBA 代码:自动调整 L9 到 L16 区域表格大小
Sub AutoSizeTable() Dim tbl As ListObject Set tbl = ActiveSheet.ListObjects('Table1') '将'Table1'替换为你的表格名称 tbl.TableStyle = 'TableStyleMedium9' '将表格样式设置为中等样式9,以便自适应大小
With tbl.TableRange1
.WrapText = False '取消换行
.EntireColumn.AutoFit '自适应列宽
.EntireRow.AutoFit '自适应行高
.HorizontalAlignment = xlCenter '水平居中
.VerticalAlignment = xlCenter '垂直居中
End With
End Sub
原文地址: https://www.cveoy.top/t/topic/mAK5 著作权归作者所有。请勿转载和采集!