+ Reply to Thread
Results 1 to 10 of 10

Copying and Pasting Unique Values

  1. #1
    Registered User
    Join Date
    09-09-2010
    Location
    Philadelphia PA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Copying and Pasting Unique Values

    I have a column which looks somewhat like this
    [Title]
    A
    B
    A
    A
    C
    0
    #NA
    A
    C

    and what I am trying to do is to copy this column Sheet1 (Range A1:A35) and paste the values on another sheet (Prespecified location... Lets say sheet 2 (Range A35) and eliminate all duplicates, 0 and #NA

    So I am trying my output on Sheet 2 (range A35) to look like
    A
    B
    C

    I did this in excel 2007 by recording a macro for autofiletr (to remove #NA and 0) and remove duplicates function under data tab.Also, I used a third sheet (Lets say.. Interim Calculations) so that I don't loose other data when I remove the duplicates. So basically copy the data from sheet1, paste it into sheet (Interim Calculations) remove o, #NA and duplicates and then copy the remainder into sheet 2. However, now that macro isn't working in 2003 version.

    I did find the post below a little helpful, but still doesn't solve my purpose.

    http://www.excelforum.com/excel-prog...que-cells.html

    Please Advise

    Thanks in Advance
    Last edited by himanshu83; 09-29-2010 at 02:25 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copying and Pasting Unique Values

    This perhaps, also utilising the Dictionary object.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-09-2010
    Location
    Philadelphia PA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Copying and Pasting Unique Values

    Hi,

    This code works perfectly fine. But here is another question which might sound really stupid... I couldn't understand what this code is really dooing.. So if I have to do the same thing ith a different column... What changes do I need to make.

    For example : Instead of Sheet1.Range"A2" .. I want to do the same thing with the data from Sheet xyz:Range C.. When I go into the code and replace range from A2 with C2:C35 . I get errors in 6th code line.

    Thanks

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copying and Pasting Unique Values

    Which error, and please specify which line you mean. Better still post your adapted code. The code transfers the range to an array which is a bit quicker (though with c30 cells negligible difference) and then adds to a dictionary if it is not already there, not #NA etc, and then outputs everything in the dictionary to the other sheet.

  5. #5
    Registered User
    Join Date
    09-09-2010
    Location
    Philadelphia PA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Copying and Pasting Unique Values

    Please find the adapted code as follows.

    The data I am copying is strictly limited to Calculation Sheet (C2:C35)
    hiddencalculation is just replacement to Interim Calculations.
    And the Output has to go to IcingOPsheet A35:A47.


    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copying and Pasting Unique Values

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-09-2010
    Location
    Philadelphia PA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Copying and Pasting Unique Values

    Hi Stephen,

    Thanks for making it simpler. However, I am still getting the type mismatch error. Please find the attached screenshots and the spreadsheet.

    Thanks in Advance.

    Himanshu
    Attached Images Attached Images
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copying and Pasting Unique Values

    Yes, it didn't like the errors in the formulae but this seems to work.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-09-2010
    Location
    Philadelphia PA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Copying and Pasting Unique Values

    Awesome...

    This is perfect.

    Thanks a lot buddy

  10. #10
    Registered User
    Join Date
    09-09-2010
    Location
    Philadelphia PA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Copying and Pasting Unique Values

    Stephen,

    I started getting the "type Mismatch" error again and after close observation, , I realize that I was getting that error only when there was nothing to sort. ie (n=0).

    I fixed it by adding a simple if statement.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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