VBA for Escape key

rmccafferty

Board Regular
Joined
Jul 16, 2009
Messages
60
How do I do the equivalent of hitting the escape key in VBA?

When I do a copy and paste in VBA, on screen in the spreadsheet it leaves the section highlighted or outlined. I do not want to see that residual outline of the area I copied or pasted. In normal usage, I would just hit the escape key to deselect the highlighted cells. How do I do that in VBA?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
For anyone else looking
This will take the marching ants away from the cells of a copied range

Application.CutCopyMode = False
 
Upvote 0
Marching Ants

For anyone else looking
This will take the marching ants away from the cells of a copied range

Application.CutCopyMode = False

I tried the above and the sendkeys('esc') without success. The marching ants remain.

The only solution I've found is to back out to the 1703 build

cd %programfiles%\Common Files\Microsoft Shared\ClickToRun
officec2rclient.exe /update user updatetoversion=16.0.7967.2161

And then turn off automatic updates.

I'm hopeful a better solution can be found as this was not a problem until the 1704 or 1705 update - i'm not sure which as i was told to go back to 1703.
 
Upvote 0
Re: Marching Ants

Try this:

SendKeys "{ESC}"
DoEvents

Notice that the parens/quotes are different. This works for me using Excel 2016 MSO (16.0.7726.1049) 64-bit on a Win10 Pro x64 version 1703 build 15063.540.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top