+ Reply to Thread
Results 1 to 5 of 5

Match similar rows from two sheets using three columns to match the "paired" rows

  1. #1
    Registered User
    Join Date
    11-04-2009
    Location
    new zealand
    MS-Off Ver
    Excel 2007
    Posts
    19

    Smile Match similar rows from two sheets using three columns to match the "paired" rows

    Hi,

    I have the final, and most important, step left in a matching macro to go but i think its over my head.

    Effectively, after much sorting, i have data in two sheets of a workbook, one contains a large amount data('large sheet"), the other much less("small sheet"). For every row in the small sheet there is a similar, but not exact, row in the "large sheet". I would like advice on the code, i assume loop, to "match" the rows from "small sheet" to the large sheet using the three columns as identifying values. All unmatched trades are not needed, i would prefer to achieve this by copying the "matched" rows from the "large sheet" and pasting it into new sheet so that i can tidy it up, but at this stage(crash course on vba code wise), i should be able to tidy it myself(google). all relevant cells are numeric.


    Extra:
    Is this possible? i could if required, move the "small sheets" data around so that the matching data is contained the same columns in both sheets, but i assume that isnt necessary. also, i need to use three columns because the sheet is large and will be used so often that i want to to be robust enough to handle the likely event of unwanted matches, is that possible, extensive google searches have left me worried it's not.
    The columns from the small sheet are E, F, I to match with the columns in G, I, L respectively.
    Any help, regardless of how incomplete would be greatly appreciated, i've recently learnt a lot(relatively speaking) on VBA so i can hopefully build on any help.
    Last edited by sanpedro_nz; 10-04-2011 at 07:25 AM.

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Match similar rows from two sheets using three columns to match the "paired" rows

    Try this one out:

    Please Login or Register  to view this content.
    The attached sheet contains the macro and some "test tabs". This puts the repeated rows into a new sheet (taken from the large sheet) and compares the columns you mentioned above.
    -if you like the macro, please rate it. Thank you,
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-04-2009
    Location
    new zealand
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Match similar rows from two sheets using three columns to match the "paired" rows

    Firstly, thanks a lot for your help.
    It's almost more than i was expecting, except it doesn't seem to like numeric values(or maybe currency). When i add the code to my spread sheet, after changing the sheet names and then run it, nothing is copied. but if i enter a, b and then c(or any other letter) in the relevant rows or columns it works, anyone have any suggestions?

    For example, these values wont match, $1 2.00 3. But if i use letters in the same sheets, column etc it works perfectly. do i need to declare them differently? ie currency or is the the way the colums are formatted affect it? also, i have matched the format in both sheets.

    Thanks again for your help, i think once finished it will work perfectly.

  4. #4
    Registered User
    Join Date
    11-04-2009
    Location
    new zealand
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Match similar rows from two sheets using three columns to match the "paired" rows

    Just to add, i recently tried to amend "Dim i As Long" and replace it with "Dim i as Currency" but it doesn't seem to work. However if i reformat the column E for both sheets to a number it works perfectly. any thoughts? I could just format every time i run this code but is it necessary? only the first is currency, the next two are numbers is that part of the issue?
    Last edited by sanpedro_nz; 09-29-2011 at 12:05 AM.

  5. #5
    Registered User
    Join Date
    11-04-2009
    Location
    new zealand
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Match similar rows from two sheets using three columns to match the "paired" rows

    All sorted now, to be honest i dont really know what the issue was. Now that its sorted it really is more than i could of ask for. Thanks a lot.

+ 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