Excel / VBA: auto-adjust column width after pastin

2020-06-13 06:12发布

I have a blank Excel table saved as a template into which I copy data from the clipboard (originating from a website).

Is there a way using VBA to auto-adjust the width of each column to its content after the data (text) has been pasted in ?

Edit: The data I paste will always be inserted starting from A1 and will always fill the same number of columns.

2条回答
家丑人穷心不美
2楼-- · 2020-06-13 06:51

You can do it with AutoFit. Like this

Columns("A:B").Select

Selection.EntireColumn.AutoFit
查看更多
女痞
3楼-- · 2020-06-13 06:54

You can perform the following:

Columns("A").Autofit
查看更多
登录 后发表回答