VBA Express Forum  




Go Back   VBA Express Forum > VBA Code & Other Help > Excel Help
     Feedback     
Register FAQ Members Arcade Knowledge Base Training Articles Consulting

Reply
 
Thread Tools Display Modes
Old 05-11-2008, 10:46 AM   #1
Cyberdude
 
Cyberdude's Avatar

 
Joined: Mar 2005
Posts: 990
Kb Entries: 2
Articles: 5
When to Use "Application.CutCopyMode" Statement

Will someone give me a short tutorial about when to use the statement "Application.CutCopyMode = "? It would seem that maybe it should be a standard statement at the end of most macros that do any copying, but I'm just guessing.

Local Time: 05:23 AM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 05-11-2008, 11:11 AM   #2
Simon Lloyd
 
Simon Lloyd's Avatar
Site Admin

 
Joined: Sep 2005
Posts: 2,835
Kb Entries: 2
Articles: 0
I don't know about tutorial as i'm no guru but here goes:
this first copy 'n' paste is how you would expect to perform the action manually, i.e all the clicks or keystrokes
VBA:
Sub Copy1() Range("A1").Select Selection.Copy Range("B1").Select ActiveSheet.Paste Application.CutCopyMode = False End Sub
VBA tags courtesy of www.thecodenet.com
thsi next one is exactly the same as the first but performed by VBA and has a specific destination whereas the first did not until you clicked it
VBA:
Sub Copy2() Range("A1").Copy Destination:=Range("B2") End Sub
VBA tags courtesy of www.thecodenet.com
the next is for copying a component of the cell, i.e the format or value ...etc, here again there is no destination cell until you click it
VBA:
Sub Copy3() Range("A1").Select Selection.Copy Range("E3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False End Sub
VBA tags courtesy of www.thecodenet.com
here's the same in a shortened version but although we have designated the cell straight away the following actions are only part of a copy and therefore copyMode is still in place for you to paste another component
VBA:
Sub Copy4() Range("A1").Copy Range("E6").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False End Sub
VBA tags courtesy of www.thecodenet.com
in short using "Application.CutCopyMode=" clears excels memory so nothing further can be pasted from that selection.

I may not be dead accurate with the explanation and someone may put me right but its as near as damn it!


Regards,
Simon
Please read this before cross posting!
In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
If I have seen further it is by standing on the shoulders of giants.
Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Local Time: 02:23 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 05-11-2008, 11:26 AM   #3
Norie

 
Joined: Jan 2005
Posts: 1,349
Kb Entries: 0
Articles: 0
Cyberdude

There might not be any need to use it anywhere.

It really depends what you are doing.

If you are using Paste or PasteSpecial then you probably should be using it.

Local Time: 02:23 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 05-11-2008, 11:27 AM   #4
Cyberdude
 
Cyberdude's Avatar

 
Joined: Mar 2005
Posts: 990
Kb Entries: 2
Articles: 5
Thanx for the reply, Simon. Basically, one might say that if you have done a lot of copying in your macro, then you can clear all the memory used by the copy operations by executing CutCopyMode. If copying just small amounts, then there's no real advantage to using CutCopyMode.
Can I assume that CutCopyMode is essentially useless if no copying has been done in the macro? I mean, is it strictly related to copying processes and no others?

Local Time: 05:23 AM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 05-11-2008, 11:47 AM   #5
Simon Lloyd
 
Simon Lloyd's Avatar
Site Admin

 
Joined: Sep 2005
Posts: 2,835
Kb Entries: 2
Articles: 0
Purely copying!


Regards,
Simon
Please read this before cross posting!
In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
If I have seen further it is by standing on the shoulders of giants.
Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Local Time: 02:23 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 05-11-2008, 11:21 PM   #6
david000
 
david000's Avatar

 
Joined: Mar 2007
Posts: 226
Kb Entries: 0
Articles: 0
There is one ultra obscure reason to check that you cleared the clipboard, but I don?t have the example anymore.

Anybody that has John Walkenbach?s aka J-Walks Pup2000 (old) AddIn with source code can see this. He used a logo that did not clear the clipboard (how it got there is the bug) if you loaded the right-click menu shortcuts.

I don?t have it on me but I did email J-Walk about this issue and he told me how to fix it (I was so in awe of him at the time).

Local Time: 09:23 AM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Old 05-12-2008, 12:20 AM   #7
mdmackillop
 
mdmackillop's Avatar
Administrator
VP-Knowledge Base

 
Joined: May 2004
Posts: 12,489
Kb Entries: 56
Articles: 2
I would use it even after small "copies" to avoid unexpected results.


MVP (Excel 2008-2010)

"Provide sample data and layout if you want a quicker solution." - MD


To help indent your macros try Smart Indent

Please remember to mark threads 'Solved'

Local Time: 02:23 PM
Local Date: 05-18-2013
Location:

 
Reply With Quote Top
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 06:23 AM.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2012 VBA Express