View Full Version : [SOLVED:] How Beneficial Is "Destination:=" to Copy?
Cyberdude
09-03-2005, 03:21 PM
When I do a copy I generally use the format:
Range("A1").Copy Range("C2")
But I just became aware of the "Destination:=" parameter, and I'm not sure what it does for you (if anything). If I used it then I would write:
Range("A1").Copy Destination:=Range("C2")
Seems like additional clutter if it's not doing anything (or is it??).
mark007
09-03-2005, 03:30 PM
Both lines of code above are equivalent.
Naming the fields can be useful for some functions, for example suppose I had a procedure:
sub MySub(Optional Arg1 as Integer, optional Arg2 as Integer, optional Arg3 as Integer)
andf I wanted to pass an argument (2) to arg3 but nothing to arg1 or arg2. There are 2 ways or doing this:
Mysub ,,2
or
MySub Arg3:=2
Both do the same thing but the second is slightly neater in this case to avoid using commas - it is easier to read.
If I only wanted to pass a value (5 say) to arg1 then I could use:
MySub 5
or
MySub Arg1:=5
As it's the first parameter I would be unlikely to use the second approach. The difference though is merely coding style and makes no real difference.
:)
Bob Phillips
09-03-2005, 05:15 PM
If you think you can always rely on MS never to change arguments or their order, and never to accidentally issue a release without screwing some up, then there is no need to worry about using named arguments.
But ...
.
Cyberdude
09-03-2005, 09:02 PM
Thanx, Guys. I get it. I just never thought of it in the context that mark007 explained. It's not so mysterious after all. :friends:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.