Excel VBA代码:自动调整表格图片大小(L9到L16)
Sub AutoresizeTable() Dim tbl As ListObject Dim rng As Range Dim tblWidth As Double Dim newWidth As Double
Set tbl = ActiveSheet.ListObjects('Table1') '表格名称
Set rng = Range('L9:L16') '表格位置
tblWidth = tbl.Range.Width '获取原始表格宽度
newWidth = rng.Width '获取新的表格宽度
'调整列宽
If tblWidth <> newWidth Then
tbl.Resize Range(tbl.Range(1, 1), rng.Cells(rng.Rows.Count, tbl.ListColumns.Count))
End If
End Sub
原文地址: https://www.cveoy.top/t/topic/mAKg 著作权归作者所有。请勿转载和采集!