Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Excel 中,如果双击右侧“边框”上的列,则可以将宽度自动调整为该列中最大值的宽度。
如何在 VBA 中复制这一点?
您可以使用宏记录器执行操作并查看;
<range>.entirecolumn.autofit
调用对象的AutoFit方法Column。
AutoFit
Column
像这样:
ActiveSheet.UsedRange.Columns.AutoFit
或者像这样:
Columns("A:A").EntireColumn.AutoFit