Match function vba

wilsonwilson4

New Member
Joined
Jun 25, 2015
Messages
13
Hi All,

Sorry i am new in mr.excel. I am wondering if there is anyway to replace "&" in Match formula and use range instead?

I have a large data set that need to compare and found if there is any different. I found that using match is very useful but it will be painful if there are many columns to be compared.

=Match(A2&B2&C2, $H$2:$H$4&$I$2:$I$4&$J$2:$J$4,0)


For example
Data Set 1 A - C column
Data 1Data 2Data 3
123​
AD
222​
BE
333​
CF

Data Set 2 H-J Column
In this case Data 2 - 222 - will have N/A or not match with data set 1
Data 1Data 2Data 3
123​
AD
222​
BD
333​
CF
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Quite frankly, I find this sort of task much easier to do in Microsoft Access where you can do Matched or Unmatched Queries based on multiple columns.

Note that Excel now offers "Power Query", which allows you to do many database-type actions (like queries like these) in Excel.
Since I am partial to Microsoft Access, I have not used Power Query myself, but there are many people here who do.
There is even a forum here for asking question about the various Power Tools: Power Tools
 
Upvote 0
you can do that very efficiently using the the VBA dictionary object. like this:
VBA Code:
Sub test()
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Ary = .Range(.Cells(1, 1), .Cells(LastRow, 3))
   Dim Dic As Object
   Set Dic = CreateObject("Scripting.dictionary")
      
   For i = 2 To UBound(Ary, 1)
        ' concatenate 3 columns
         tt = ""
         For j = 1 To 3
         tt = tt & Ary(i, j)
         Next j
         Dic(tt) = i
   Next i
End With

With Worksheets("Sheet2")
LastRow = .Cells(Rows.Count, "H").End(xlUp).Row
datar = .Range(.Cells(1, 8), .Cells(LastRow, 10))
outarr = .Range(.Cells(1, 7), .Cells(LastRow, 7))
For i = 2 To LastRow
         tt = ""
         For j = 1 To 3
         tt = tt & datar(i, j)
         Next j
         If Dic.Exists(tt) Then
         outarr(i, 1) = Dic(tt)
         Else
         outarr(i, 1) = "Not Found"
         End If
Next i
 .Range(.Cells(1, 7), .Cells(LastRow, 7)) = outarr
End With
End Sub
 
Upvote 0
Solution
Thanks for the replay.. may I know what query u use in access? It seems only allow 1 column with query wizard unmatched.
That is only if you use the Query Wizard (which, you do not have to do, that is only a tool to help people along).
You can actually start out with the Unmatched Query Wizard (which only joins on one field).
Then, when you finish setting it up, you can edit the query to join on the other fields to.

Any basic/introductory book/video/tutorial on creating queries in Access will show you how to join on multiple fields in a query (it is a very common thing to do).

This tutorial shows you how to do an Unmatched Queries when joining on multiple fields (see the "Create and modify a Find Unmatched Query to compare by more than one field" section):
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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