Setting selection to Nothing when programming Excel

后端 未结 17 1930
误落风尘
误落风尘 2021-02-02 09:35

When I create a graph after using range.copy and range.paste it leaves the paste range selected, and then when I create a graph a few lines later, it uses the selection as the f

17条回答
  •  终归单人心
    2021-02-02 10:11

    If using a button to call the paste procedure,

    try activating the button after the operation. this successfully clears the selection

    without

    • having to mess around with hidden things
    • selecting another cell (which is exactly the opposite of what was asked)
    • affecting the clipboard mode
    • having the hacky method of pressing escape which doesn't always work

    HTH

    Sub BtnCopypasta_Worksheet_Click()
       range.copy
       range.paste
    BtnCopypasta.Activate
    End sub
    

    HTH

提交回复
热议问题