+ Reply to Thread
Results 1 to 7 of 7

Paste Special within If Statement

  1. #1
    Registered User
    Join Date
    09-17-2014
    Location
    Telford
    MS-Off Ver
    2010
    Posts
    12

    Paste Special within If Statement

    Hi, I have read through a few posts and online searches on how to get Paste Special to work with into an IF statement.

    This is what I have constructed (which doesn't work). I have tried adding code to the end of the if statement as suggested to me but the IF statement doesn't like that.

    Any help greatly appreciated

    Jon




    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 07-19-2016 at 05:37 AM.

  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: Paste Special within If Statement

    Hi Jon,

    You can't use Copy and PasteSpecial on the same line. It needs to be two separate operations. However it looks as though you are pasting everything anyway so PasteSpecial is not required. If that is indeed the case then all you need is this:
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Paste Special within If Statement

    Hi,

    Please remember to add code tags to your code as per the forum rules. I've added them for you this time but not for the next time.

    What sort of PasteSpecial action are you wanting? In general the .PasteSpecial instruction needs to be followed by a modifier. e.g.

    Please Login or Register  to view this content.
    assuming it values that you are wanting to paste. Or maybe (xlPasteAll)..
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    09-17-2014
    Location
    Telford
    MS-Off Ver
    2010
    Posts
    12

    Re: Paste Special within If Statement

    Hi,

    Sorry new to writing in this thread will try and abide by he rules going forward.

    I need to paste the values, I have tried to add the code your code into the IF statement and it returns an error.

  5. #5
    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: Paste Special within If Statement

    If you do require pastespecial, then it must be two separate operations:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-17-2014
    Location
    Telford
    MS-Off Ver
    2010
    Posts
    12

    Re: Paste Special within If Statement

    Thanks Guys, works a treat

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Paste Special within If Statement

    Yes, sorry. Doing it that way it should have been on two lines

    Worksheets("table").Range("B3:bn3").Copy
    Worksheets("import_table").Range("A2:BM2").PasteSpecial(xlPasteValues)

+ 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. How to copy, paste, delete to special cell with if-then-statement in csv.file?
    By Riva in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2014, 11:32 PM
  2. copy formula and paste for new data added and autofill.....and paste special values
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2014, 07:40 AM
  3. Trap Catch Differentiate Disable Paste Button from Paste Special Options
    By m3atball in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2013, 07:28 PM
  4. Replies: 1
    Last Post: 12-05-2012, 11:37 AM
  5. VBA for Paste special when IF statement is TRUE ?
    By archangel9999 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-29-2012, 06:39 AM
  6. [SOLVED] how can I paste text using paste special, without clicking paste button?
    By Exxcel Noob in forum Excel General
    Replies: 6
    Last Post: 05-14-2012, 08:21 PM
  7. characters / paste special-paste link / absolute/relative default
    By LWD in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-29-2005, 08:20 PM

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