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.
Press one of the following keyboard shortcuts: To AutoFit column width: Alt + H, then O, and then I. To AutoFit row height: Alt + H, then O, and then A.
Select cells you want to auto resize or CTRL + a for all cells. Menu Home tab -> Format->Column->AutoFit Row/Column Height.
You can do it with AutoFit
:
Columns("A:B").EntireColumn.AutoFit
You can perform the following:
Columns("A").Autofit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With