Below is a case where .PasteSpecial works but .Paste does not:
1. Does this strike anyone else as odd?![]()
Please Login or Register to view this content.
2. I'm a coding junky so I'd like to do this in one step, e.g. range("A1:B1").copy dest:=range("A2:A5").
Setting that aside (see item 3 below), I sure don't want to use THREE lines: (I hope you don't mind the notation change from item 1)
YET! this way works without resorting to pastespecial. Why is that? I cringe at the "having to select" - Coding 101 says strive to avoid Selects, right?![]()
Please Login or Register to view this content.
(Sure, it's going to be selected anyway by virtue of the paste. It still feels aggravating to add the select code line.)
Maybe the bottom line is just that you can .PasteSpecial against ranges but not .Paste, but I'm stubbornly resisting that?
3. range("A1:B1").copy dest:=range("A2:A5")
fails. What am I doing wrong
Bonus questions, aside from this example. You can skip everything past this point.
4. Sometimes in code I'd like to go Selection.Paste, yet it won't execute, but this will:
Activesheet.Paste
I wonder why Activesheet. is required. After all, if I just went Control-V (which this code is intended to duplicate), Excel would know exactly where to post - over the selection! Besides, it would seem that explicitly specifying Selection would theoretically lighten the load on VBA (so he doesn't have to "resolve where to do something" at runtime). (Okay, busted; I realize that Selection itself must be resolved at runtime. Still...)
4A. Since Selection.Paste fails, is Activesheet.Paste the proper or best alternative, or something else?
5. When you have 2 window instances (foo.xls:1 and foo.xls:2 in the window caption) and you go
range("A2:A5").pastespecial
while instance 2 is active, instance 1 also selects A2:A5 (even if it was on row 999). I wish instance 1 would be unaffected. Any perspective on that? (BTW there are some commands that insist on operating on instance 1, such as F5 go to).
TIA
Bookmarks