deselecting a highlighted range after a VBA copy procedure

  • Thread starter Thread starter Paul James
  • Start date Start date
P

Paul James

I've noticed that when I run a copy and paste operation in VBA using
statements of the form

Worksheet1.Range1.Copy
Worksheet2.Range2.pastespecial

that target range, Range2, remains selected unless I perform some other
operation on a range in Worksheet2.

I would like to unselect that range after the paste method is executed, but
I'd rather not use a Select method at that point in my code, because I don't
want to make Worksheet2 the active sheet. Is there a way to deselect that
highlighted range without using a Select statement?

Thanks in advance.

Paul
 
I don't believe there is a way without switching to the second sheet and
switching back.
 
Paul,
If you are transferring values, I think this will work without selecting
the range:

Worksheet2.Range2.Value = Worksheet1.Range1.Value

I also know that:
Worksheet1.Range1.Copy Worksheet2.Range2

will work, but this is not PasteSpecial, of course.

Alex J
 
Paul,

This worked for me from recording a Macro such as you described then
checking the code:

Application.CutCopyMode = False

-gk-
 
Thanks for the response, gk.

Unfortunately, while Application.cutcopymode = false turns off the
highlighted marquee from the range that was copied from, but it doesn't
deselect the range that was copied to.

See Alex's suggestion elsewhere in this thread for a way to get the desired
effect.

Paul
 
Back
Top