Complex problem! Highlight text string differences between conditional rows

ms.g

New Member
Joined
Feb 24, 2012
Messages
2
Hi everyone,

I have a worksheet with 10,000+ rows of data across columns A-Q. Every few rows are identical apart from one string of text in one of the columns. I need both to be able to identify the column where the discrepancy occurs and display the variations in the text. An example would probably help!

(NB columns R & S are how I would like the results to be displayed - full explanation below!)

<html><table><tr height=21><td width=22> </td><td width=64>A</td><td width=39>B</td><td width=60>C</td><td width=60>D</td><td width=60>E</td><td width=33>…</td><td width=60>L</td><td width=80>M</td><td width=80>N</td><td width=80>O</td><td width=110>P</td><td width=53>Q</td><td width=80>R</td><td width=80>S</td> </tr> <tr height=24><td width=22>1</td><td width=64>Name</td><td width=39>ID</td><td width=60>Stat #1</td><td width=60>Stat #2</td><td width=60>Stat #3</td><td width=33>…</td><td width=60>Stat #10</td><td width=80>text #1</td><td width=80>text #2</td><td width=80>text #3</td><td width=110>text #4</td><td width=53>text #5</td><td width=80>RESULT:</td><td width=80>RESULT:</td> </tr> <tr height=12><td width=22>2</td><td width=64>Example</td><td width=39>20</td><td width=60>13</td><td width=60>15</td><td width=60>49</td><td width=33>…</td><td width=60>908</td><td width=80>some text</td><td width=80>more text</td><td width=80>other text</td><td width=80>text again</td><td width=110>lots text</td><td width=80>text #3</td><td width=80>"other"</td> </tr> <tr height=12><td width=22>3</td><td width=64>Example</td><td width=39>20</td><td width=60>14</td><td width=60>16</td><td width=60>47.6</td><td width=33>…</td><td width=60>4250</td><td width=80>some text</td><td width=80>more text</td><td width=80>extra text</td><td width=110>text again</td><td width=53>lots text</td><td width=80>text #3</td><td width=80>"different"</td> </tr> <tr height=12><td width=22>4</td><td width=64>Another</td><td width=39>20</td><td width=60>23</td><td width=60>25</td><td width=60>63.4</td><td width=33>…</td><td width=60>811</td><td width=80>excel</td><td width=80>ppt</td><td width=80>word</td><td width=110>thanks mrexcel</td><td width=53>outlook</td><td width=80>text #4</td><td width=80>"thanks"</td> </tr> <tr height=12><td width=22>5</td><td width=64>Another</td><td width=39>20</td><td width=60>24</td><td width=60>26</td><td width=60>54.3</td><td width=33>…</td><td width=60>811</td><td width=80>excel</td><td width=80>ppt</td><td width=80>word</td><td width=110>thank u mrexcel</td><td width=53>outlook</td><td width=80>text #4</td><td width=80>"thank u"</td> </tr> <tr height=12><td width=22>6</td><td width=64>Another</td><td width=39>20</td><td width=60>25</td><td width=60>27</td><td width=60>49.8</td><td width=33>…</td><td width=60>1754</td><td width=80>excel</td><td width=80>ppt</td><td width=80>word</td><td width=110>thanks mrexcel!</td><td width=53>outlook</td><td width=80>text #4</td><td width=80>"thanks", "!"</td> </tr></table></html>

I guess the first step is to identify rows where the contents of both columns A and B (i.e. the Name and ID) are identical. Then, I'll need to be able to compare these rows across columns M-Q to identify:
1) Where the cells' contents are not identical
2) The text differences
In the table above, I've mocked up how I'd like the results to be displayed (columns R & S). The results of 1) are displayed in column R, while the results of 2) are displayed in column S.

There are two examples in the table above; here's how they work:

i. Rows 2 & 3 are compared because the Name column ("Example") and ID column ("20") both match. The text strings in columns M through to Q are identical in rows 2 & 3 APART from in column O ("text #3"). Here, row 2 says "other text" while row 3 says "extra text". Thus, in results column R (which identifies the column in which the rows' contents differ) "text #3" is displayed. Column S displays the variance itself: in row 2 this is "other"; in row 3 this is "extra".

ii. Rows 4, 5 & 6 are compared because the Name column ("Another") and ID column ("20") both match. The text strings in columns M through to Q are identical in rows 4, 5 & 6 APART from in column P ("text #4"). Here, row 4 says "thanks mrexcel", row 5 says "thank u mrexcel", and row 6 says "thanks mr excel!". Thus, in results column R, "text #4" is displayed. Column S, again, displays the variance itself: in row 4 this is "thanks", in row 5 this is "thank u" and in row 6 this is both "thanks" and "!".

I hope this all makes some kind of sense to somebody, and that you might be able to help me get columns R and S to display what I need them to.

Thanks MrExcel!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
The formula for column R will work provided
1. Col A and B are sorted A=Primary and B=secondary
2. There are no more than 3 matching A/B rows .
3. Discrepancy exist only in 1 column of M thru P - otherwise it reports 1st col with discrepancy

The Col S formula will show you the entire contents of the cell that is different in that row rather than only the specific word differences

Enter in R2 and copy down:
=IF(COUNTIFS(A:A,A2,B:B,B2)=1,"Unique Row",IF(AND(A2=A1,B2=B1),R1,IF(COUNTIFS(A:A,A2,B:B,B2)=2,IF(M2<>M3,M$1,IF(N2<>N3,N$1,IF(O2<>O3,O$1,IF(P2<>P3,P$1,IF(Q2<>Q3,Q$1,"Identical"))))),IF(COUNTIFS(A:A,A2,B:B,B2)=3,IF(OR(M2<>M3,M2<>M4),M$1,IF(OR(N2<>N3,N2<>N4),N$1,IF(OR(O2<>O3,O2<>O4),O$1,IF(OR(P2<>P3,P2<>P4),P$1,IF(OR(Q2<>Q3,Q2<>Q4),Q$1,"Identical"))))),"Over 3 Rows"))))

Enter in S2 and copy down:
IF(R2=M$1,M2,IF(R2=N$1,N2,IF(R2=O$1,O2,IF(R2=P$1,P2,IF(R2=Q$1,Q2,"")))))
 
Upvote 0

Forum statistics

Threads
1,216,106
Messages
6,128,863
Members
449,473
Latest member
soumyahalder4

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