+ Reply to Thread
Results 1 to 5 of 5

alternative methods to sumproduct for comparing/matching rows

  1. #1
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    alternative methods to sumproduct for comparing/matching rows

    In VBA i've been using the formula below to compare a row (A2:D2) on Sheet2 with 50 rows (A2:D51) on Sheet1 to see if any of the rows on Sheet1 match my A2:D2 row on Sheet2.

    Please Login or Register  to view this content.
    If a row on Sheet1 matches the row in Sheet2, the formula returns a 1, if there is no matching row in Sheet1 the formula returns a 0. Although the above method works well, I worry it may return a 1 by mistake, in the case where i have only a few characters/numbers/letters in the rows being compared, and produces a match when there isnt.

    Any alternative ways in VBA to compare rows on seperate sheets?
    Last edited by intothewild; 11-17-2012 at 07:11 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: alternative methods to sumproduct for comparing/matching rows

    without seeing a sample of what you are working with, its hard to say. but have you tried playing around with vlookup()?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: alternative methods to sumproduct for comparing/matching rows

    The simplest solution would be to create a helper column on each sheet. The formula in each helper column would be =A2&"|"&B2&"|"&C2&"|"&D2 to collate the data.
    Then you can use COUNTIF or VLOOKUP to verify the data on sheet 1 against sheet 2. I suspect that would be much quicker than a complex SUMPRODUCT though I have no reason to believe that SUMPRODUCT won't work.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: alternative methods to sumproduct for comparing/matching rows

    Quote Originally Posted by FDibbins View Post
    without seeing a sample of what you are working with, its hard to say. but have you tried playing around with vlookup()?
    sample1.xls

    sure, file attached. usually try to avoid v-lookups, keep getting problems with them when looking across multiple sheets.
    Last edited by intothewild; 11-17-2012 at 07:29 PM.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: alternative methods to sumproduct for comparing/matching rows

    in column E on both sheets, combine the data using =A2&B2&C2&D2, copied down

    then in sheet2, column F, use this, copied down...
    =IF(ISERROR(VLOOKUP(E2,Yesterday!E2:$E$50,1,FALSE)),"",1)

    the resulting 1's would be the "found"

+ 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