Excel VBA 自动调整 L9 到 L16 区域表格图片大小
Sub ResizeTable() Dim tbl As ListObject Set tbl = ActiveSheet.ListObjects('Table1') '修改为你的表格名称
'计算表格的宽度和高度
Dim tblWidth As Double, tblHeight As Double
tblWidth = tbl.Range.Width
tblHeight = tbl.Range.Height
'计算单元格的宽度和高度
Dim cellWidth As Double, cellHeight As Double
cellWidth = tblWidth / tbl.Range.Columns.Count
cellHeight = tblHeight / tbl.Range.Rows.Count
'调整每个单元格的大小
Dim row As Range, col As Range
For Each col In tbl.Range.Columns
For Each row In tbl.Range.Rows
With row.Cells(col.Column)
.RowHeight = cellHeight
.ColumnWidth = cellWidth
End With
Next row
Next col
End Sub
原文地址: https://www.cveoy.top/t/topic/mALK 著作权归作者所有。请勿转载和采集!