Macro help find duplicates in two columns

  • I need a macro that will search two columns and locate any duplicates between the two columns. Here is an example of my data:


    [TABLE="width: 895"]

    [tr]


    [td]

    3051CD2A22A1AS1E5M5CNJ3-1199WDAB3AFFW71DC00

    [/td]


    [td]

    3051SFPDS010W3M0800D31AA1A2KDM5C5

    [/td]


    [/tr]


    [tr]


    [td]

    3051CG4A04A1AH3E5CN

    [/td]


    [td]

    475HP1EKLUGMT

    [/td]


    [/tr]


    [tr]


    [td]

    03031-0313-0013

    [/td]


    [td]

    3051CD2A03A1AH2E5CN

    [/td]


    [/tr]


    [tr]


    [td]

    475HP1EKLUGMT

    [/td]


    [td]

    3144PD1A1E5M5Q4CNB4

    [/td]


    [/tr]


    [/TABLE]



    The first column is column "A". The second column is column "B". In column "C", I want the output to be 475HP1EKLUGMT in the cell 2. The macro needs to run until the last used cell in each column has been checked for duplicates.


    Thanks,
    J

  • Re: Macro help find duplicates in two columns


    J


    Does this give you what you need?


  • Re: Macro help find duplicates in two columns


    Quote from dangle;605894

    J


    Does this give you what you need?



    This code works for the columns A and B, but what if I want to look for duplicates in column D vs. column A, and then output that in column E?

  • Re: Macro help find duplicates in two columns


    Change

    Code
    Columns("B")


    to

    Code
    Columns("D")


    The duplicate value will be listed in the column one to the right of the one you are matching. You can adjust this with the 'offset' line.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!