+ Reply to Thread
Results 1 to 10 of 10

VBA Copy and Paste Values

  1. #1
    Registered User
    Join Date
    08-24-2014
    Location
    Swansea
    MS-Off Ver
    Office 365
    Posts
    99

    VBA Copy and Paste Values

    Hi all,
    I have a small amount of code copying a coulmn and pasting the unique values in another part of the sheet; however it is copying the formulas. I have tried to incorporate "PasteSpecial xlPasteValues" into my code but have not been able to get it working.

    Any help is greatly appreciated, please see below for code.

    thanks

    Leigh

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,226

    Re: VBA Copy and Paste Values

    You can't do PasteSpecial like that. You have to have two separate calls. (Note that I have removed the comma after PasteSpecial)

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA Copy and Paste Values


    Hi,

    an easy Excel basics way to extract unique values is to use an advanced filter and thus whatever manually or under VBA …
    As it seems you are under Excel 365 version you have the worksheet function UNIQUE.

  4. #4
    Registered User
    Join Date
    08-24-2014
    Location
    Swansea
    MS-Off Ver
    Office 365
    Posts
    99

    Re: VBA Copy and Paste Values

    Hi Jeff,
    Thanks for the reply, I did try this initially, it gives me a Compile Error: Expected: end of statement

    thanks
    Leigh

  5. #5
    Registered User
    Join Date
    08-24-2014
    Location
    Swansea
    MS-Off Ver
    Office 365
    Posts
    99

    Re: VBA Copy and Paste Values

    Hi Marc,
    I have used UNIQUE to extract distinct values before but have not had success using it to extract all unique values, I.E copy all values and remove any duplicates.

    Have you used this function in this way?

    thanks

    Leigh

  6. #6
    Registered User
    Join Date
    08-24-2014
    Location
    Swansea
    MS-Off Ver
    Office 365
    Posts
    99

    Re: VBA Copy and Paste Values

    Ahh thank you Jeff, that has worked perfectly!!!!

    Appreciate the support!!

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA Copy and Paste Values


    As I'm not under 365 version but according to many theads using this function it well works if the logic is respected.

    If you follow the top page yellow banner in order to attach a sample workbook I'm sure Jeff will help you for 365 ways
    like me with beginner level Excel basics 'cause, as a reminder, an easy advanced filter just needs a single codeline
    like you can operate yourself just activating the Macro Recorder …

  8. #8
    Registered User
    Join Date
    08-24-2014
    Location
    Swansea
    MS-Off Ver
    Office 365
    Posts
    99

    Re: VBA Copy and Paste Values

    Thanks Marc, I always like to try and work it out first so will actually see if that's an easier way of doing it

    Also thanks for your support!!

    Leigh

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,226

    Re: VBA Copy and Paste Values

    I agree with Marc that if all you are doing is trying to get a list of unique values, the UNIQUE function in 365 is much simpler than a VBA solution.

  10. #10
    Registered User
    Join Date
    08-24-2014
    Location
    Swansea
    MS-Off Ver
    Office 365
    Posts
    99

    Re: VBA Copy and Paste Values

    Hi both,
    just to follow up on this thread, Jeff your solution did work very well but as Marc suggested to try Unique, I tried to see if this was an easier option. I have successfully now got the formula to the way I had it working with the macro and of course this now runs without the need of initiating afore mentioned macro.

    For anyone coming across this thread the formula to return all distinct value from column D into your selected output column is as follows:

    Please Login or Register  to view this content.
    Again thanks both for the support and happy to give reputation points for you both!!

+ 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. Use VBA to Copy & Paste Unique Value from One Worksheet to Another (Paste as Values)
    By jhiltz725 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2021, 03:12 PM
  2. Copy Paste Issue Merge Cell & Paste Values other Column
    By majidsiddique in forum Excel General
    Replies: 12
    Last Post: 04-28-2020, 01:07 AM
  3. Autofill Copy and Paste , Cant copy/paste the values
    By fluffyvampirekitten in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2015, 06:10 AM
  4. Copy Formulas and Paste into the Last Set # of Rows Only & Paste Values
    By Mr. Ice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2014, 07:48 AM
  5. 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
  6. Vba - find next empty column, insert column, copy paste values & copy paste formulas
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:43 PM
  7. VBA Copy-paste values with changing paste location
    By booost in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-16-2012, 10:39 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