PDA

View Full Version : To a.Copy/b.Paste or to b.Value=a.Value



chamster
09-14-2007, 01:33 AM
Which method is to be more prefered?

a) Value assignment.

.Range(X).Value=.Range(Y).Value


b) Copy/paste operation.

.Range(Y).Copy
Z.Paste Destination:=X

johnske
09-14-2007, 02:07 AM
a) is faster for small ranges, but becomes slower when very large ranges are involved (but don't ask me where the break-even point is :))

rory
09-14-2007, 02:17 AM
Your second one ought to be:


.Range(Y).Copy .Range(X)

FWIW.

chamster
09-14-2007, 03:21 AM
Yes, it ought. I'm not saying "thanks you". I'm saying "i love you". :bow:

Is it the same as using the following?

.Range(Y).Copy Destination:=.Range(X)


Once again - there's got to be a reference somewhere on such "what's up and what's doable with e.g. .Copy"... You can't all have learned from eachother. Somebody's got to be the first one who's read the stuff somewhere. Where?

No? Really. Oh...:mkay

Bob Phillips
09-14-2007, 03:26 AM
It starts with Microsoft, they wrote the product, and they disseminated info out. Others picked it up, played with it and learnt more, then passed that on in various fourms, CompuServe, public NGs, these new-fangled web forums, etc., and so it goes.

There is no substitute for using it and learning what it can and what it can't do. If you aren't naturally a programmer, there are more places to get help than you could possibly EVER need.

rory
09-14-2007, 04:08 AM
Yes, it's the same. The only variation is that your version uses named arguments, which means you can provide them in any order if there is more than one. If you don't name the arguments, you have to provide them in the order expected, or leave blanks separated by commas for any optional ones. So:
range("A1").Replace what:="blah", replacement:="blad", matchcase:=true
or:
range("A1").Replace "blah", "blad", , , true
because Replace expects (optional) LookAt and SearchOrder arguments before the MatchCase one.

If you weren't supplying the MatchCase argument, the second one would just be:
range("A1").Replace "blah", "blad"

because the arguments you do specify are in the right order anyway.

chamster
09-14-2007, 05:56 AM
You are a gold mine!