I need to create a macro (or function) to copy cells from an adjacent worksheet to the current worksheet if they meet certain criteria.
Below is the worksheet adjacent to the current worksheet that contains the Owner, Ticket, and Comments fields. I need to copy those fields to the appropriate application name and object (Concatenated as a unique ID) in the current worksheet.

Below is the current worksheet that I need to copy the above fields to. Notice that the applications are not listed in the same order. This will be the case as I never know which order the data will be in or if the same data will even be in the new worksheet.

So far I have tried this function:
=IF(INDIRECT(NextSheetName()&”!A3″)&INDIRECT(NextSheetName()&”!B3″) = A3&B3, INDIRECT(NextSheetName()&”!D3″), “0”)
Which will work only in the case that the worksheets have the same data in the same order.
Does anyone have any idea how this can be done?
If you want to do this using VBA, try the following. The code copies matching rows from the source worksheet to the target worksheet and records the matching row on the source to the target, in case you find that useful. I named my sheets “Source” and “Target” and am assuming that you are wanting to match on the concatenation of columns A and B.
The number of rows in your source and target don’t matter, nor does the order in which the matches appear.
I wrote two different versions. The first works, but I’m not crazy about it because it loops through the source range looking for a match for each value in the target. The second version uses a dictionary that is built once. Matching search terms is then done without having to loop through a range. Note that to use the dictionary, you’ll need a reference to the Microsoft Scripting Runtime.
First Version: (functional, but requires multiple loops)
Second Version: (optimized, requires reference to Microsoft Scripting Runtime)
Here’s what your references will look like once you’ve correctly selected the Microsoft Scripting Runtime: