+ Reply to Thread
Results 1 to 5 of 5

Situations that require .PasteSpecial (No args) instead of .Paste

  1. #1
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Situations that require .PasteSpecial (No args) instead of .Paste

    Below is a case where .PasteSpecial works but .Paste does not:
    Please Login or Register  to view this content.
    1. Does this strike anyone else as odd?

    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)
    Please Login or Register  to view this content.
    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? (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
    Last edited by Oppressed1; 11-16-2017 at 06:56 AM. Reason: Arggh, the VERY FIRST LINE was erroneous, now fixed

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Situations that require .PasteSpecial (No args) instead of .Paste

    1. The Range object has a PasteSpecial method but not a Paste method. So not odd at all, in spite of your stubborn resistance.
    2. A Worksheet does have a Paste method. That method also has a destination argument
    Please Login or Register  to view this content.
    3. The argument is called Destination not Dest:
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: Situations that require .PasteSpecial (No args) instead of .Paste

    3 perfectly concise useful answers to 2 useful questions (Let's forget I asked number 3 ). I completely missed the destination arg for activesheet.paste, so you especially saved me there.

    Concise and useful. May every answer shine that way +1 Reputation.

    I'll just concede that item 5 is "one of those things" to endure.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Situations that require .PasteSpecial (No args) instead of .Paste

    Thanks.

    Re #5, if you can use the one line copy + destination you avoid that issue.

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Situations that require .PasteSpecial (No args) instead of .Paste

    And since a Range Object doesn't have a Paste method:
    Please Login or Register  to view this content.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Selection.PasteSpecial Paste:=xlValues
    By diegosened in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2013, 07:53 PM
  2. [SOLVED] PasteSpecial Paste:=ColumnWidths
    By Arvi Laanemets in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-12-2012, 10:09 AM
  3. Does pastespecial require sheet be active?
    By geoB in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-25-2009, 11:20 AM
  4. Excel 2007 : Paste and PasteSpecial
    By Rick_Stanich in forum Excel General
    Replies: 7
    Last Post: 06-06-2008, 03:36 PM
  5. Pastespecial - paste values
    By sapphire in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-28-2008, 06:19 PM
  6. [SOLVED] Paste vs PasteSpecial
    By Gary''s Student in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2006, 02:35 PM
  7. paste negative time with PasteSpecial
    By Sylvian in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 09-02-2005, 02:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1