+ Reply to Thread
Results 1 to 11 of 11

Compare two lists and copy unique values to the second list

  1. #1
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2010
    Posts
    179

    Compare two lists and copy unique values to the second list

    Hi all,

    I'm having a problem. I have a spreadsheet where the values in column C should contain all of the values in A (starting from C3 and A3). Column C may contain values that are not in A.

    Effectively, what I would like the macro to do, on a button push, would be to look at the values in A, check to see if the values is in C, and if it is not, copy the value to the next available row in C.

    Any bright ideas? All help is much appreciated.
    Did I help? Click *- add to my rep.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare two lists and copy unique values to the second list

    You can use Index and match, but if you want a code, please attach your sample.

  3. #3
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2010
    Posts
    179

    Re: Compare two lists and copy unique values to the second list

    Quote Originally Posted by AB33 View Post
    You can use Index and match, but if you want a code, please attach your sample.
    It has to be hard coded. It will become apparent when you see the sheet. Column A of 'RM Input Table' is a pivot based on the query in 'RM Query'. I need to copy the missing values from A into C to hardcode those values - I then plan to index/match the relevant data from RM query into the rest of the table and then be able to add my own data at the end.

    Thanks.
    Last edited by Brumbot; 06-06-2013 at 07:38 AM.

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Compare two lists and copy unique values to the second list

    Hi Brumbot,

    Can you post a sample workbook indicating your expected results ? thanks.


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  5. #5
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Pune
    MS-Off Ver
    Office 365 (Win 10)
    Posts
    489

    Re: Compare two lists and copy unique values to the second list

    I dont think that macro is required. Please have a look at the attached filevalues-missing-in-list-1-that-exists-i-list-21.xls

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Compare two lists and copy unique values to the second list

    Column C may contain values that are not in A.
    and

    look at the values in A, check to see if the values is in C, and if it is not, copy the value to the next available row in C.

    If c contains all A, the missing must be in column A. You should return what is in C, but in A to A.
    I also do not understand why can not you use a simple Vlookup formula.

  7. #7
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2010
    Posts
    179

    Re: Compare two lists and copy unique values to the second list

    Quote Originally Posted by akhileshgs View Post
    I dont think that macro is required. Please have a look at the attached fileAttachment 241087
    OK. The values in the left hand list may change as information is deleted from the database. Since I have hardcoded inputted information from the user in the blue areas of my spreadsheet (right hand side), if I were to use an index/match, the number would change, but the hardcoded information would remain in the same place and not refer to the correct number. I assure you, it has to be coded.

    I should add that if a value drops off the column A, and is already in C, it should remain in C.
    Last edited by Brumbot; 06-06-2013 at 06:48 AM.

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Compare two lists and copy unique values to the second list

    Hi Brumbot,
    maybe so
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2010
    Posts
    179

    Re: Compare two lists and copy unique values to the second list

    Quote Originally Posted by nilem View Post
    Hi Brumbot,
    maybe so
    Please Login or Register  to view this content.
    This is great! Other than the fact that if it finds one in the middle of the range that is not included in C, it pastes it with a 1 row gap at the bottom. Is there any way to make it so that it paste without the gap?

  10. #10
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Compare two lists and copy unique values to the second list

    Quote Originally Posted by Brumbot View Post
    ... if it finds one in the middle of the range that is not included in C... Is there any way to make it so that it paste without the gap?
    It is not very clear. Can you show a small example of this

  11. #11
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2010
    Posts
    179

    Re: Compare two lists and copy unique values to the second list

    Quote Originally Posted by nilem View Post
    It is not very clear. Can you show a small example of this
    Never mind. This works as expected. Thanks very much for your input.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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