Identifying all rows where conflicting entries exist

BigRods

Board Regular
Joined
Dec 16, 2011
Messages
68
Hi,

I'm looking for a way of identifying all entries for a Patient ID where the Patient ID's have conflicting "Country of Birth" entries recorded.

Entries for each Patient ID may all say either ZZZ or GBR, but they cannot say both.
The problem with identifying them being that:

Rows may list the country of birth in this order (easy):
ZZZ
GBR

or they may be as follows:
ZZZ
ZZZ
GBR

ZZZ
GBR
ZZZ
(i.e not in a set order)

I need to find a formula that enters "1" in column D for all entries for that Patient ID that have any conflicting data in there - is this possible? Alternately, if there is an easier way of identifying all records? Hope this makes sense!


My data looks as follows - ID's 17038 and 1788532 are fine, but 1497921 needs to be identified as there are conflicting entries recorded:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Patient ID[/TD]
[TD]Date Recorded[/TD]
[TD]Country of Birth[/TD]
[TD]Error?[/TD]
[/TR]
[TR]
[TD]17038[/TD]
[TD]24-Jun-17[/TD]
[TD]ZZZ[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]1497921[/TD]
[TD]27-Apr-17[/TD]
[TD]ZZZ[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1497921[/TD]
[TD]19-Jun-17[/TD]
[TD]ZZZ[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1497921[/TD]
[TD]14-Jun-17[/TD]
[TD]GBR[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1788532[/TD]
[TD]06-May-17[/TD]
[TD]GBR[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]1788532[/TD]
[TD]30-Apr-17[/TD]
[TD]GBR[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
If you fail to get a formula response , try this code ,it will do what you want !!!!
Code:
[COLOR="Navy"]Sub[/COLOR] MG09Aug16
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Q [COLOR="Navy"]As[/COLOR] Variant, K [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Not .Exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
        .Add Dn.Value, Array(Dn.Offset(, 2).Value, 0, Dn)
    [COLOR="Navy"]Else[/COLOR]
        Q = .Item(Dn.Value)
            [COLOR="Navy"]If[/COLOR] Not Q(0) = Dn.Offset(, 2).Value [COLOR="Navy"]Then[/COLOR] Q(1) = 1
            [COLOR="Navy"]Set[/COLOR] Q(2) = Union(Q(2), Dn)
        .Item(Dn.Value) = Q
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys
    .Item(K)(2).Offset(, 3) = .Item(K)(1)
[COLOR="Navy"]Next[/COLOR] K
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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