Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deselect range selected by copy function 1

Status
Not open for further replies.

ninjamyst

Programmer
Jan 28, 2005
21
US
When a range is selected for copying, there's a dotted outline around the range. After the copy-paste operation is done, the range is still selected. I know that in Excel, you can manually deselect any range by double clicking on a cell. However what's the right way to do it via code? I have tried SomeCell.select and SomeCell.Activate but the dotted outline still remains in the copy range.
 

You can do a couple of things. Easiest way is to copy/paste in one command:
[tt]
Sub test()
Selection.Copy [F1]
End Sub
[/tt]
Alternatively you can set the CutCopyMode to False (which is what I think you are asking for):
[tt]
Sub test2()
Selection.Copy
Range("F1").PasteSpecial
Application.CutCopyMode = False
End Sub
[/tt]

 

and yet another option...

You may well need to have this Selection, for instance if the macro begins AFTER the user selects a range.

However, in most other cases, using the Select and Activate methods is not necessary and may even significantly slow down the execution of your code.

Check out this FAQ...

How Can I Make My Code Run Faster? faq707-4105

Skip,

[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue]


 
Dependant on needs - if you just want a straight copy/paste then

Range("CopyRange").copy destination:=Range("PasteRange")

will not utilise the clipboard and will be a: faster and b: will not leave the "marching ants"

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top