Search code examples
excelmaxsequential

Excel, find max value for a collection of sequence


In column A, I have a collection of sequential data.They all start from 1, but end with different numbers. I wish I can create a column B, which has the max number for each sequence. Is there any formula can help me do this? These numbers are in different cells.eg.A1=1 A2=2 A3=3.....

A  123123412
B  333444422

Solution

  • If the numbers aren't in the same cell and the sequences always start with 1 you can just look for the next 1 in the column and go back 1 (except for the last sequence where you need to find the last number in the column):

    =IFERROR(INDEX(A$1:A$100,MATCH(1,A2:A$100,0)+ROW()-1),LOOKUP(999,A$1:A$100))
    

    enter image description here

    This is shorter but has to be entered as an array formula using Ctrl-Shift-Enter (CSE):

    =INDEX(A1:A$99,MATCH(TRUE,A2:A$100<A1:A$99,0))
    

    Non-CSE version

    =INDEX(A1:A$99,MATCH(TRUE,INDEX(A2:A$100<A1:A$99,0),0))