Is there a function in Excel to find the first cell with a different value than the previous one

Uumas

New Member
Joined
Oct 8, 2017
Messages
3
Here's a demonstration of what I want to achieve, but in a much larger scale: https://imgur.com/a/8FZvA
So in the A column there's numbers which can be anything really and I need to list them in C column. I can easily do it manually on an example that small, but I have a sheet with ~30 different numbers on 500 rows. So is there a function I could use to do that?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
in C2 enter the following ....

=IFERROR(INDEX($A$2:$A$37, MATCH(0,COUNTIF($C$1:C1, $A$2:$A$37), 0)),"")

Change $A$37 to whatever you want to be the last cell in the range.

Enter it as an array formula ... ie: press ctrl shift enter, not just enter

drag down as far as you need, and you will have your list

Kind regards,

Chris
 
Upvote 0
[Table="width:, class:grid"][tr][td]Row\Col[/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][/tr][tr][td]
1​
[/td][td][/td][td][/td][td]
4​
[/td][/tr]
[tr][td]
2​
[/td][td]
2​
[/td][td][/td][td]result[/td][/tr]
[tr][td]
3​
[/td][td]
3​
[/td][td][/td][td]
2​
[/td][/tr]
[tr][td]
4​
[/td][td]
1​
[/td][td][/td][td]
3​
[/td][/tr]
[tr][td]
5​
[/td][td]
1​
[/td][td][/td][td]
1​
[/td][/tr]
[tr][td]
6​
[/td][td]
5​
[/td][td][/td][td]
5​
[/td][/tr]
[tr][td]
7​
[/td][td]
5​
[/td][td][/td][td][/td][/tr]
[tr][td]
8​
[/td][td]
2​
[/td][td][/td][td][/td][/tr]
[tr][td]
9​
[/td][td]
1​
[/td][td][/td][td][/td][/tr]
[/table]


In C1 just enter:

=SUM(IF(FREQUENCY(A2:A9,A2:A9),1))

In C3 control+shift+enter, not just enter, and copy down:

=IF(ROWS($C$3:C3)>$C$1,"",INDEX($A$2:$A$9,SMALL(IF(FREQUENCY(IF(ISNUMBER($A$2:$A$9),MATCH($A$2:$A$9,$A$2:$A$9,0)),ROW($A$2:$A$9)-ROW($A$2)+1),ROW($A$2:$A$9)-ROW($A$2)+1),ROWS($C$3:C3))))

The foregoing keeps the order of occurrence in the data. If this is irrelevant, as an option in C3 control+shift+enter and copy down:

=IF($C$3:C3)>$C$1,"",MIN(IF(ISNA(MATCH($A$2:$A$9,$C$2:C2,0)),$A$2:$A$9)))
 
Upvote 0
Leave e.g. A3 empty. Do you still get the list you are after?
Aladin
I think the same question would apply to your second solution (after inserting the missing bit)

=IF(ROWS($C$3:C3)>$C$1,"",MIN(IF(ISNA(MATCH($A$2:$A$25,$C$2:C2,0)),$A$2:$A$25)))
 
Upvote 0
Aladin
I think the same question would apply to your second solution (after inserting the missing bit)

=IF(ROWS($C$3:C3)>$C$1,"",MIN(IF(ISNA(MATCH($A$2:$A$25,$C$2:C2,0)),$A$2:$A$25)))

Simply add an ISNUMBER test.

=IF(ROWS($C$3:C3)>$C$1,"",MIN(IF(ISNUMBER($A$2:$A$25),IF(ISNA(MATCH($A$2:$A$25,$C$2:C2,0)),$A$2:$A$25))))

I was merely addressing the unique list formulas:lookaway:...
 
Upvote 0
I was merely addressing the unique list formulas:lookaway:...
;)

If the data is numeric and order is not important, here is another way, that doesn't require the C+s+e entry.


Book1
ABC
1Original6
21Result
31
412
514
616
718
819
92
102
112
122
134
144
158
168
179
186
196
20
List 2
Cell Formulas
RangeFormula
C1=SUM(IF(FREQUENCY(A2:A24,A2:A24),1))
C3=IF(ROWS(C$3:C3)>C$1,"",SMALL(A$2:A$20,COUNTIF(A$2:A$20,"<="&C2)+1))
 
Upvote 0
Hi,

If the data is numeric and order is important, here is another way, that doesn't require the CSE entry.

Code:
C3 =IFERROR(INDEX($A$2:$A$9,MATCH(0,INDEX(COUNTIF($C$2:C2,$A$2:$A$9),0,0),0)),"")
 
Last edited:
Upvote 0
Hi,

If the data is numeric and order is important, here is another way, that doesn't require the CSE entry.

Code:
C3 =IFERROR(INDEX($A$2:$A$9,MATCH(0,INDEX(COUNTIF($C$2:C2,$A$2:$A$9),0,0),0)),"")

In-between empty cells will still cause havoc.

By the way, it's still array-processing formula. Replacing control+shift+enter with an INDEX call is not generic, that is, it won't hold for all array-processing cases requiring control+shift+enter (CSE).

The obsession with CSE has apparently convinced Google Sheets: This spreadsheet software has an extra function called ARRAYFORMULA, so we get in all cases:

=ARRAYFORMULA(array-processing-formula)

followed by just enter.

Perhaps Excel could introduce something like:

#IF(ROWS($C$3:C3)>$C$1,"",INDEX($A$2:$A$9,SMALL(IF(FREQUENCY(IF(ISNUMBER($A$2:$A$9),MATCH($A$2:$A$9,$A$2:$A$9,0)),ROW($A$2:$A$9)-ROW($A$2)+1),ROW($A$2:$A$9)-ROW($A$2)+1),ROWS($C$3:C3))))

or

=#IF(ROWS($C$3:C3)>$C$1,"",INDEX($A$2:$A$9,SMALL(IF(FREQUENCY(IF(ISNUMBER($A$2:$A$9),MATCH($A$2:$A$9,$A$2:$A$9,0)),ROW($A$2:$A$9)-ROW($A$2)+1),ROW($A$2:$A$9)-ROW($A$2)+1),ROWS($C$3:C3))))

followed by just enter. Hopefully parsing for # is as cheap as parsing for control+shift+enter.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
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