Find Duplicate query
Author
Discussion

DaveH23

Original Poster:

3,355 posts

201 months

Sunday 11th March 2018
quotequote all
Not sure if I am missing something here but can't seem to get this to work.

I have a workbook with hundereds perhaps even thousands of rows.

I want to higlight duplicate values but only if multiple columns are the same.

Assuming the following is in Column A, B & C;
1 2 3
1 2 2
1 2 3
1 2 4

I want it to only highlight row 1 and 3 as duplicates, is this possible?

akirk

5,778 posts

145 months

Sunday 11th March 2018
quotequote all
simple way would be to create col 4 and combine the other columns to read 123
then just dedup which is a built in feature, based on that new column...

there is probably a clever way to do it, but this will take a couple of seconds to do...

DaveH23

Original Poster:

3,355 posts

201 months

Sunday 11th March 2018
quotequote all
The columns contain a random combination of text and numbers. That was purely an example.

akirk

5,778 posts

145 months

Sunday 11th March 2018
quotequote all
DaveH23 said:
The columns contain a random combination of text and numbers. That was purely an example.
so was mine...

for d1 enter
=a1&b1&c1
then copy down...
now use coulmn d to de-duplicate

DaveH23

Original Poster:

3,355 posts

201 months

Monday 12th March 2018
quotequote all
akirk said:
so was mine...

for d1 enter
=a1&b1&c1
then copy down...
now use coulmn d to de-duplicate
Ah I see what you mean, will give it a go.

Cheers.

maffski

1,905 posts

190 months

Monday 12th March 2018
quotequote all
akirk said:
for d1 enter
=a1&b1&c1
This won't (quite) work, for example:

1 23 4 = 1234
12 3 4 = 1234


You need to add a delimiter, so D1 would be something like =A1 & "," & B1 & "," & C1 which would give
1,23,4
12,3,4

akirk

5,778 posts

145 months

Monday 12th March 2018
quotequote all
maffski said:
akirk said:
for d1 enter
=a1&b1&c1
This won't (quite) work, for example:

1 23 4 = 1234
12 3 4 = 1234


You need to add a delimiter, so D1 would be something like =A1 & "," & B1 & "," & C1 which would give
1,23,4
12,3,4
fair point smile

paulrockliffe

16,694 posts

258 months

Monday 12th March 2018
quotequote all
Sort the data by the columns you want to test, so that any duplicates are next to each other. Then add a column with a formula that tests the row below on those columns to see if it's the same. If it is, return a flag, if it isn't, look to see if the row above is the same, if it is return a flag. If it isn't, return nothing.

Eg. IF(AND(A5=A6, B5=B6,C5=C6)=TRUE, 1, IF(AND(A5=A4, B5=B4, C5=C4)=TRUE, 2, ""))

This will give you a column that you can use to highlight duplicates, which is what you asked for as apposed to the solutions above that are deleting the duplicates. If you want to delete the duplicates, by labelling them 1 and 2, you can choose which to delete, or use the Remove Duplicates tool that's built in.

4x4Tyke

6,506 posts

163 months

Monday 12th March 2018
quotequote all
I assuming your use of the word workbook means you are talking spreadsheet not database, this would work with both but there are better ways to do it with a database.

A fourth column is correct but use a hash function on the fields you want to use for duplicate detection. In layman terms a hash function will add up all the values of the chosen fields to create a single hash value. Rows with identical hash values mean all the fields are equal. There are some technical caveats but they shouldn't cause you any issue here if manually review each highlighted duplicate before action. Sort by the hash column to surface the duplicates.

The main limitation of a hash function is that it may create some false positives, but the chance of this on few thousand records is vanishingly small. It will not miss duplicates.


Edited by 4x4Tyke on Monday 12th March 10:29