Excel / VBA: auto-adjust column width after pasting data

后端 未结 3 964
孤独总比滥情好
孤独总比滥情好 2021-02-14 10:35

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

3条回答
  •  無奈伤痛
    2021-02-14 11:13

    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.

提交回复
热议问题