Get the Max Value until criteria is met

xKidz

New Member
Joined
Apr 12, 2019
Messages
16
I have a spreadsheet with over 2000 lines

I will start by explaining the above picture.
Columns AO and AP are there just for explanation purposes.
My expected results are in column AP.
Each value from the AN (Miles Column) are connected with a PostCode (Column AK).

I would like the formula to start when "First Line" in column G is met and stop when another "First Line" is met.
I would like the formula to take the max value from Column AN but just for the "First Line" to "First Line range" and then restart again.
Then I would like the formula to apply the PostCode to the lines where "Multi Drop" from column J shows up.

I have tried a few formulas with Match and Index but i just don't know how to restart the count whenever i hit "First Line" again.


EDIT:
Also posted here
https://www.excelforum.com/excel-fo...-value-until-criteria-is-met.html#post5112649
 
Last edited by a moderator:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
try this


Book1
ABCD
1First LinePO130PO4
2PO258
3PO349
4PO481
5PO553
6First LinePO615PO8
7PO726
8PO832
9PO924
10PO1010
11PO117
12First LinePO1271PO12
13PO1318
14PO1435
15PO1544
16PO1614
17First LinePO1744
Sheet2
Cell Formulas
RangeFormula
D1=IFERROR(INDEX(OFFSET(A1,0,1,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),MATCH(MAX(OFFSET(C1,0,0,MATCH("First Line",OFFSET(A1,1,0,2000,1),0),1)),OFFSET(A1,0,2,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),0)),"")
 
Upvote 0
try this

ABCD
1First LinePO130PO4
2PO258
3PO349
4PO481
5PO553
6First LinePO615PO8
7PO726
8PO832
9PO924
10PO1010
11PO117
12First LinePO1271PO12
13PO1318
14PO1435
15PO1544
16PO1614
17First LinePO1744

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
D1=IFERROR(INDEX(OFFSET(A1,0,1,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),MATCH(MAX(OFFSET(C1,0,0,MATCH("First Line",OFFSET(A1,1,0,2000,1),0),1)),OFFSET(A1,0,2,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),0)),"")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>


Hi,

This is working as expected, thanks alot.
Any way that i can remove all the other values if First Line is not present ?

Looks like this for now

Zywzcrt
 
Upvote 0
you're welcome

not quite sure about your follow on question, what after values you wanted to remove?
 
Upvote 0
it should work, check your formula again


Book1
ABCD
1First LinePO130PO4
2PO258
3PO349
4PO481
5PO553
6First LinePO615PO8
7PO726
8PO832
9PO932
10PO1032
11PO117
12First LinePO1271PO12
13PO1371
14PO1471
15PO1571
16PO1614
17First LinePO1744
Sheet1
Cell Formulas
RangeFormula
D1=IFERROR(INDEX(OFFSET(A1,0,1,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),MATCH(MAX(OFFSET(C1,0,0,MATCH("First Line",OFFSET(A1,1,0,2000,1),0),1)),OFFSET(A1,0,2,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),0)),"")
 
Upvote 0
Hi,

I have added an IF NOT statement before the formula which takes care of the things.
I would like to ask something else though, i have added a new value in Column A "Single Drop", is there any way that your formula can ignore the post code of this line?
Also there will be the problem that the formula doesn't calculate on the last array of cells.

Your help is much appreciated
 
Upvote 0
one way i can think of is to create a helper column that can be hidden like this


Book1
ABCDE
1First LinePO13030PO2
2PO25858
3PO34949
4Single DropPO4810
5PO55353
6First LinePO61515PO8
7PO72626
8PO83232
9PO93232
10PO103232
11PO1177
12First LinePO127171PO12
13PO137171
14PO147171
15PO157171
16PO161414
17First LinePO174444
Sheet1
Cell Formulas
RangeFormula
D1=IF(A1="Single Drop",0,C1)
E1=IFERROR(INDEX(OFFSET(A1,0,1,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),MATCH(MAX(OFFSET(D1,0,0,MATCH("First Line",OFFSET(A1,1,0,2000,1),0),1)),OFFSET(A1,0,3,MATCH(A1,OFFSET(A1,1,0,2000,1),0),1),0)),"")
 
Upvote 0
glad that help, you're welcome
 
Upvote 0

Forum statistics

Threads
1,217,349
Messages
6,136,050
Members
449,986
Latest member
rittersportyummy

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