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
You can do it with a worksheet change event, but if your worksheet is changed in any way after the paste, it runs again. Not an issue unless you're trying to hide columns to focus on a subset of data because they will autofit themselves constantly.
I recommend using a button to paste the data and including the column width setting as part of the paste command.
You can perform the following:
Columns("A").Autofit
You can do it with AutoFit
:
Columns("A:B").EntireColumn.AutoFit