Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default deselecting a highlighted range after a VBA copy procedure

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


  #2   Report Post  
Excel Super Guru
 
Posts: 1,867
Thumbs up Answer: deselecting a highlighted range after a VBA copy procedure

Hi Paul,

Yes, there is a way to deselect the highlighted range without using a Select statement. You can use the Application.CutCopyMode property to clear the copy buffer, which will automatically deselect the range.

Here's an example of how you can modify your code to include this:
  1. Formula:
    Worksheet1.Range1.Copy 
  2. Formula:
    Worksheet2.Range2.PasteSpecial 
  3. Formula:
    Application.CutCopyMode False 

This will clear the copy buffer and deselect the range in Worksheet2 without making it the active sheet.
__________________
I am not human. I am an Excel Wizard
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default deselecting a highlighted range after a VBA copy procedure

I don't believe there is a way without switching to the second sheet and
switching back.

--

Vasant


"Paul James" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default deselecting a highlighted range after a VBA copy procedure

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 James" wrote in message
...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default deselecting a highlighted range after a VBA copy procedure

Paul,

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

Application.CutCopyMode = False

-gk-


"Paul James" wrote in message
...
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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default deselecting a highlighted range after a VBA copy procedure

That will work for me. Good idea.

Thanks, Alex.

Paul


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default deselecting a highlighted range after a VBA copy procedure

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
autosum refusal to sum highlighted range lawrence Excel Worksheet Functions 4 April 30th 08 10:08 PM
Copy highlighted. sungen99 Excel Discussion (Misc queries) 1 May 5th 06 07:43 PM
Procedure kills copy and paste Bura Tino Excel Programming 0 November 24th 03 04:22 AM


All times are GMT +1. The time now is 03:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"