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:
Patient IDDate RecordedCountry of BirthError?
1703824-Jun-17ZZZ0
149792127-Apr-17ZZZ1
149792119-Jun-17ZZZ1
149792114-Jun-17GBR1
178853206-May-17GBR0
178853230-Apr-17GBR0

<tbody>
</tbody>
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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