stop summing if hits value

hehehihi2007

New Member
Joined
Jul 20, 2024
Messages
1
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
  8. 2003 or older
Platform
  1. Windows
Hi, newbie here,

kindly your help, i have sheet contain production, price & sales
and I want to stop sum when the production is >= sales, and get the last row number, is it possible using the formula?

thx in advance

NB. yellow columns is the result i want.
 

Attachments

  • sum.png
    sum.png
    7.6 KB · Views: 34

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Why is the result 110,000? Your total sales is 167,500.
 
Upvote 0
For 2021 version
In J2
Excel Formula:
=LET(a,SUMIF(OFFSET($B$2,0,0,ROW($B$2:$B$7)-ROW($B$1)),">0"),b,BYROW(I2:I5,LAMBDA(x,SMALL(IF(a>x,a,""),1))),c,BYROW(I2:I5,LAMBDA(x,SMALL(IF(a>x,ROW($B$2:$B$7),""),1))),HSTACK(b,c))
For other versions ARRAY formulas
In J2
Excel Formula:
=SMALL(IF(SUMIF(OFFSET($B$2,0,0,ROW($B$2:$B$7)-ROW($B$1)),">0")>=$I2,SUMIF(OFFSET($B$2,0,0,ROW($B$2:$B$7)-ROW($B$1)),">0"),""),1)
In K2
Excel Formula:
=SMALL(IF(SUMIF(OFFSET($B$2,0,0,ROW($B$2:$B$7)-ROW($B$1)),">0")>=$I2,ROW($B$2:$B$7),""),1)
Both copied down.
To enter ARRAY formula
Copy and paste the formula in cell
Press F2
Press Ctrl+Shift+Enter together
Excel covers the formula with {}.


10000​
75000​
110000​
3​
100000​
12500​
110000​
3​
100000​
30000​
110000​
3​
100000​
50000​
110000​
3​
100000​
100000​
 
Upvote 0
Option to avoid OFFSET.
Book1
ABCDEF
1dateprodsalesprodrow
211000075,0001100003
3210000012,5001100003
4310000030,0001100003
5410000050,0001100003
65100000
76100000
87
Sheet1
Cell Formulas
RangeFormula
A2:A8A2=SEQUENCE(7)
E2:E5E2=LET(a,TRANSPOSE($B$2:$B$7),b,COLUMNS(a),m,MMULT(a,N(SEQUENCE(b)<=SEQUENCE(,b))),MIN(IF(m>=D2,m)))
F2:F5F2=LET(a,TRANSPOSE($B$2:$B$7),b,COLUMNS(a),m,MMULT(a,N(SEQUENCE(b)<=SEQUENCE(,b))),XMATCH(TRUE,D2<=m)+1)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,923
Messages
6,175,401
Members
452,640
Latest member
steveridge

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