Compare text values in mutiple columns, and ignore cells

GHARRISON

New Member
Joined
Nov 29, 2017
Messages
4
Can someone please help provide a formula to comparing text values in multiple columns, for differences, and ignore blanks

For example below:

if the values (excluding blanks) in B,C,D,E match then F = "OK"

if the values (excluding blanks) in B,C,D,E do not match then F = "Diffrerence"

ABCDEF
Item 1BE20BE20OK
Item 2CZ28BE20Difference
Item 3BE20BE20BE20GB35Difference
Item 4CZ28OK
Item 5CZ28CZ28OK
Item 6BE12OK
Item 7BE20BE20BE20OK
Item 8BE20CZ28CZ28CZ28Difference
Item 9CZ28CZ28OK

Thanks in advance for any help/tips!
 
Last edited by a moderator:
Joe4 - Thank you so much, this works perfectly! I must admit, I don't fully understand the formula, but it works, and works on different ranges (number of columns)!

I struggled for hours earlier, but could not find a solution... so you have made my day - thanks!:smile:
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You are welcome!

It actually isn't quite as confusing as it looks, except for that LOOKUP part.
Basically, we are just taking the count of non-blank entries and subtracting the number of entries equal to the last cell in that row with an entry.
If it is zero, it means the counts match (meaning all the entries are the same).
The COUNTA and COUNTIF functions are pretty straightforward. The part of the code that find that last non-empty entry in the row is the tricky part (I included a link that shows where that came from).
 
Upvote 0
Welcome to the Board!

What we can do is compare the count of the total number of entries in each row to the total number of entries matching the last non-blank entry in that row (see this for details on finding the last non-blank entry in a row: How to return the first / last non blank cell in a row or column?).

So, for row 2, the formula would look like:
Code:
=IF(COUNTA(B2:E2)-COUNTIF(B2:E2,LOOKUP(2,1/(B2:E2<>""),B2:E2))=0,"OK","Difference")
You can copy that formula down for all the other rows, and it should work. In my testing, it matches your expected results exactly.
Hi, I have an exact requirement like the original question, however, I have a vlookup formula to return blank("") if no values from other tabs. So, the code considered the cells with formula as not blanks and returned "difference" for all. Is there any way I could considered only the cells that has values. Thanks.
 
Upvote 0
Welcome to the Board!

Hi, I have an exact requirement like the original question, however, I have a vlookup formula to return blank("") if no values from other tabs. So, the code considered the cells with formula as not blanks and returned "difference" for all. Is there any way I could considered only the cells that has values. Thanks.

See if this variation works:
Rich (BB code):
=IF(SUMPRODUCT(--(B2:E2<> ""))-COUNTIF(B2:E2,LOOKUP(2,1/(B2:E2<>""),B2:E2))=0,"OK","Difference")
 
Upvote 0
Welcome to the Board!



See if this variation works:
Rich (BB code):
=IF(SUMPRODUCT(--(B2:E2<> ""))-COUNTIF(B2:E2,LOOKUP(2,1/(B2:E2<>""),B2:E2))=0,"OK","Difference")
Thanks Rich. It worked :)
 
Upvote 0
Welcome to the Board!

What we can do is compare the count of the total number of entries in each row to the total number of entries matching the last non-blank entry in that row (see this for details on finding the last non-blank entry in a row: How to return the first / last non blank cell in a row or column?).

So, for row 2, the formula would look like:
Code:
=IF(COUNTA(B2:E2)-COUNTIF(B2:E2,LOOKUP(2,1/(B2:E2<>""),B2:E2))=0,"OK","Difference")
You can copy that formula down for all the other rows, and it should work. In my testing, it matches your expected results exactly.
Hi Joe4,

The Lookup function has a limit at 255 characters. Do you have a solution for that if you have text inputs with more than 255 characters?

Cheers!
 
Upvote 0
Hi Joe4,

The Lookup function has a limit at 255 characters. Do you have a solution for that if you have text inputs with more than 255 characters?

Cheers!
Nope.

Since the details of your question is different than the original one asked, it would be best for you to post it to a new thread, instead of posting to an existing old thread.
That way it will appear as a new question in the "Unanswered threads" listing and will get a lot more looks/attention (as many people looking to help go right to that list).
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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