+ Reply to Thread
Results 1 to 5 of 5

Compare cell values in two different columns for mismatches

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Compare cell values in two different columns for mismatches

    In column A is a list of Invoice Numbers
    In column B is a list of Client ID Numbers

    Each unique invoice number in column A should correspond to the same Client ID Number in Column B.

    I am trying to find a formula that would find all instances in which any invoice number is assigned to two or more different client IDs.

    For example, in column A, I have five instances of invoice number 125000. For two of the 5, the client ID number is 700. For the other three, the client ID is 55005500. I want to be able to identify cases when this occurs.

    I have attached a sample of data with expected results in column E. Thanks in advance for any comments.
    Attached Files Attached Files
    Last edited by maacmaac; 02-11-2012 at 01:34 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Compare cell values in two different columns for mismatches

    In the attached workbook I've used 3 helper columns in this solution - the first in column G joins together the Invoice number and the client number using this formula:

    =A2&"_"&B2

    The next column (H) reduces this to a unique list using this array formula:

    =IF(ISNA(INDEX($G$2:$G$28, MATCH(0, COUNTIF($H$1:H1, $G$2:$G$28), 0))), "", INDEX($G$2:$G$28, MATCH(0, COUNTIF($H$1:H1, $G$2:$G$28), 0)))

    The final helper column counts the occurrences of the invoice number within the unique list using this formula:

    =IF(H2="","",COUNTIF(H:H,LEFT(H2,SEARCH("_",H2))&"*"))

    All three formulae have been copied down to the bottom of your data (row 28), and I've coloured the cells pale yellow so you can see this.

    Then this formula in E2 gives you what you wanted:

    =IF(VLOOKUP(A2&"_"&B2,H:I,2,0)>1,"No match","match")

    Again, this is copied down. If you have more data in reality, then the G$28 in the second formula would need to be changed (4 times).

    Hope this helps.

    Pete
    Attached Files Attached Files

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Compare cell values in two different columns for mismatches

    It works fine except it takes a really long time to run. I should have mentioned I am running this using excel 2010 and have almost 100,000 lines of data I need to analyze. Would it be possible to actually do this using VBA to shorten the time to process? Thanks

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Compare cell values in two different columns for mismatches

    Here's a conditional formatting formula to highlight those invoices that do not match...

    =NOT(SUMPRODUCT(--(A2&B2=A:A&B:B))=COUNTIF(A:A,A2)

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Compare cell values in two different columns for mismatches

    Perfect. Thanks

+ 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