Finding the first cell in a range that does not match a value

leepox

New Member
Joined
May 5, 2016
Messages
4
Hi all, I want to find the first cell that does not match a certain value.

For example I have this data:


First non
blank
value
First non-
matching
value
Column
Reference
Data 1Data 2Data 3Data 4Data 5
AAAB4 AA AAABAA

<tbody>
</tbody>


The first 3 columns are the results. The rest of the columns are data. I have the following equation in Cell A2:

=INDEX(D5:FC5, MATCH("*", D5:I5, 0))

This returns the first non-blank text data and I use this as the reference value. The equation I require is for cell B2 which is to find the first non AA value. To makes matters more complex, the BLANK cells do not count as a change. So I guess the 2 questions are:

1. Find the first cell that does not match the reference value, and
2. How do I ignore the blank cells to find the first non-match value.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
With your sample data in A1:I5 (repeating your test row)

This formula returns the first non-blank value
Code:
A5: =INDEX(D5:FC5, MATCH("*", D5:I5, 0))

This formula returns the value of the first non-blank, non-matching cell
Code:
B5: =INDEX(D5:I5,MATCH(1,INDEX((D5:I5<>"")*(D5:I5<>A5),0),0))

And this formula returns the cell count between those two values
Code:
C5: =MATCH(B5,D5:I5,0)-MATCH(A5,D5:I5,0)+1

Is that something you can work with?
 
Upvote 0
Hi Ron,

Wow. This is exactly what I needed! I would never have figured out to do it this way. I have been pulling my hair for the past few hours, so thank you ever so much for stopping me from getting completely bald! :biggrin:

Kind Regards
 
Upvote 0
Hi leepox,
I realize that I have arrived late to the "party". Can you use something like this? I have 3 formulas: first non-blank item, first non-blank non-matching item, and first exact item. Hope this helps.
Mike Szczesny


Excel 2012
ABCDEFGH
1a
2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3Awcaxda
4
5xxxxxxxx
Sheet1
Cell Formulas
RangeFormula
A5{=INDEX($A$2:$H$2,MATCH(TRUE,$B$3:$H$3<>"",0))}
B5{=INDEX($A$2:$H$2,MATCH(TRUE,$A$3:$H$3<>$A$1,0))}
C5{=INDEX($A$2:$H$2,MATCH(1,--EXACT($A$3:$H$3,$A$1),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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