Count Unique Records in 2 Columns

cameronb

Board Regular
Joined
Feb 13, 2009
Messages
146
I have searched the forums and found many posts on this topic, but not one which resolves the below issue.

If you had 2 columns of data: A with christian names B with surnames

E.g.

A B
David Smith
Peter Smith
Chris Brown
Peter Smith
And you wanted to count the unique number of names in columns A and B, is there a formulae which can compute this, excluding blanks. In the above example it would be 3.

I have tried a variety of sumproduct and frequency formulae to no evail include the likes of:

Code:
=SUMPRODUCT(--(FREQUENCY(MATCH(A1:A4&B1:B4,A1:A4&B1:B4,0),ROW(A1:B4))>0))

Any help on this I would be most grateful.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try this formula courtesy of Ron Coderre

=SUMPRODUCT((A1:A4&B1:B4<>"")*(MATCH(A1:A4&B1:B4,A1:A4&B1:B4,0)=ROW(A1:B4)-ROW(A1)+1)+0)
 
Upvote 0
Array wise:

Code:
=SUM(IF(FREQUENCY(IF(A1:A4&B1:B4<>"",MATCH(A1:A4&"@"&B1:B4,A1:A4&"@"&B1:B4,0)),ROW(A1:A4)-ROW(A1)+1)>0,1))
confirmed with CTRL + SHIFT + ENTER

SUMPRODUCT wise

edit: below eff. same as BH's above

Code:
=SUMPRODUCT((A1:A4&B1:B4<>"")*(MATCH(A1:A4&"@"&B1:B4,A1:A4&"@"&B1:B4,0)=(ROW(A1:A4)-ROW(A1)+1)))

below would work but would be open to inaccuracy re:blanks whereas the first two would not.

Code:
=SUMPRODUCT((FREQUENCY(MATCH(A1:A4&"@"&B1:B4,A1:A4&"@"B1:B4,0),ROW(A1:A4)-ROW(A1)+1)>0)+0)
 
Upvote 0
Try
Code:
=SUM(IF(A1:A10&B1&B10=A1:A10&B1:B10,1,0))
entered as array formula (CTRL+SHIFT+ENTER)

FORGET IT - I just found a problem in my formula and when correcting it, found the formula did not work. apologies.
 
Last edited:
Upvote 0
Just wanted to say a BIG thanks for the solution above. It solved my problem too! Just wish I could understand the durn code!
But Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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