How to find dupelicate coordinates values store in 2 different column?

VBA_Cancer

New Member
Joined
Nov 6, 2017
Messages
17
Hi, right now I have a spreadsheet like this:

A | ​B
1 | 2
2 | 2
1 | 5
2 | 2
1 | 2
3 | 4

I want to return the number of duplicate coordinates for each coordinates. So an EXCEL VBA function that loops through each coordinates and msgbox how many times it's duplicated. Assume the number of rows is 6.

Ex. for (1, 2) it would return 2.

Is it possible to use countif for this? Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You can do that with Countifs
=COUNTIFS(A$1:A$6,A1,B$1:B$6,B1)
 
Upvote 0
You don't really need VBA for this. You can show the number of times each set appears in another column in the same row.
So, let's say that you have a header/title row in row 1, and your data begins on row 2.
Then, in cell C2 you can enter this formula and copy down:
Code:
=COUNTIFS($A:$A,$A2,$B:$B,$B2)
 
Upvote 0
You could use countif. In column C string together the values of A & B =concatenate(A1,b1) then in column D you can do a countif =COUNTIF(C:C,C1)
 
Upvote 0
You could use countif. In column C string together the values of A & B =concatenate(A1,b1) then in column D you can do a countif =COUNTIF(C:C,C1)
I would not recommend that. That could lead to incorrect results.
For example, if one row had 12 in column A, and 3 in column B, and another row had 1 in column A and 23 in column B, that methodology would incorrectly identify them as duplicates.
Use COUNTIFS, which allows for multiple conditions.
 
Upvote 0
You could use countif. In column C string together the values of A & B =concatenate(A1,b1) then in column D you can do a countif =COUNTIF(C:C,C1)
As a follow-up to my previous response, if you had wanted to use that method (maybe because you are on an old version of Excel that does not have COUNTIFS), you could make a slight modification that would allow it to work.
Use something like:
Code:
[COLOR=#333333]=concatenate(A1,[/COLOR][COLOR=#ff0000]","[/COLOR][COLOR=#333333],B1)[/COLOR]
 
Last edited:
Upvote 0
thank you for your response, but I need it in VBA as I am writing a program.
How about this UDF (user defined function)...
Code:
[table="width: 500"]
[tr]
	[td]Function CoordCount(Rng As Range, Acoord As String, Bcoord As String)
  CoordCount = UBound(Split(Join(Evaluate("TRANSPOSE(" & Rng.Columns(1).Address & "&""|""&" & Rng.Columns(2).Address & ")"), "@"), Acoord & "|" & Bcoord))
End Function[/td]
[/tr]
[/table]
This function takes three arguments... the range containing all of the coordinates, the coordinate from Column A and the coordinate from Column B. So, for the example you gave, you could use this formula...

=CoordCount($A$1:$B$6,1,2)

or...

=CoordCount($A$1:$B$6,A1,B1)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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