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.
Many thanks in advance, Tim.
You can do it with AutoFit. Like this
Columns("A:B").Select Selection.EntireColumn.AutoFit
Lê Tuấn Thành
You can perform the following:
Columns("A").Autofit
来源:https://stackoverflow.com/questions/24058774/excel-vba-auto-adjust-column-width-after-pasting-data