Case- and character sensitive match and count with VBA

lopiteaux

Board Regular
Joined
Jun 8, 2011
Messages
77
Hi,

I need to compare 2 datasets, both with ~20k records, and determine whether a record in dataset A is present in dataset B.

The keys I need to compare need to take into account:
- case sensitivity (the keys are only unique when this distinction is made);
- wildcards (the keys can contain *, ?, ~, &, $, <, etc.)


I can accomplish the task using an exact match lookup (below), but the calculation time is ~10-15mins. Is there a better and faster way to do this via VBA?

{=INDEX(data_column,MATCH(TRUE,EXACT(value,lookup_column))}

Cheers,
l.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Could you show us a sample of your data,, indicating what column/s to look in?
Also what do you want to happen if a match is found?
 
Upvote 0
A sample value is "@$E109*201|RTS22" - unfortunately I cannot share a sample as the data is highly confidential.

I need to return the row number of the MATCH, in the same way that a traditional MATCH works. I'm having to expand the MATCH to include the EXACT function given the special characters and case sensitivity.
 
Upvote 0
I need to compare 2 datasets, both with ~20k records, and determine whether a record in dataset A is present in dataset B.
Where are your two data sets located (sheet name or names, columns starting row)?

Where should the output go (next column)?
 
Upvote 0
Where are your two data sets located (sheet name or names, columns starting row)?

Where should the output go (next column)?

The structure is as follows:
- Lookup values in D2:D20001 on sheet 'baseline';
- MATCH range in C2:C20001 on sheet 'report';
- INDEX range in E2:E20001 on sheet 'report';
- Response from INDEX/MATCH in E2:E20001 on sheet 'baseline';

Apologies for being vague!
 
Upvote 0
Is this what your after
Code:
Sub CompareCopy()

   Dim Valu As String
   Dim Cl As Range
   Dim BaseWs As Worksheet
   Dim RepWs As Worksheet
   
   Set BaseWs = Sheets("Test")
   Set RepWs = Sheets("SBD")
   With CreateObject("scripting.dictionary")
      For Each Cl In RepWs.Range("C2", RepWs.Range("C" & Rows.Count).End(xlUp))
         If Not .exists(Cl.Value) Then .Add Cl.Value, Cl.Offset(, 2).Value
      Next Cl
      For Each Cl In BaseWs.Range("D2", BaseWs.Range("D" & Rows.Count).End(xlUp))
         If .exists(Cl.Value) Then Cl.Offset(, 1).Value = .Item(Cl.Value)
      Next Cl
   End With

End Sub
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top