First cell with a value of 0 after a certain row

Hipsterpotamus

New Member
Joined
Aug 17, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I need to determine the range of values from Column A in my dataset where the corresponding values values in Column B are not equal to 0. Finding the the first value (in this example, 7) is easy enough, but the last value is giving me some issues. Anyone have any advice on how to solve this problem?

Thank you!

Book1.xlsx
ABCDE
110FirstLast
2207
330
440
550
660
771
885
997
101010
11115
12126
13130
14140
15150
16160
17170
18180
19190
20200
Sheet4
Cell Formulas
RangeFormula
D2D2=INDEX(A1:A99998,MATCH(TRUE,INDEX(B:B>0,0),))
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Another option
Fluff.xlsm
ABCDE
110FirstLast
220712
330
440
550
660
771
885
997
101010
11115
12126
13130
14140
15150
16160
17170
18180
19190
20200
Sheet5
Cell Formulas
RangeFormula
D2:E2D2=XLOOKUP(TRUE,B1:B1000>0,A1:A1000,,,{1,-1})
Dynamic array formulas.
 
Upvote 0
Thank you for the responses, but neither solution quite work.

I used a bad example in my first post. The full data has multiple ranges where the values are greater than 0. So both formulas would give me the value of the last cell with a value greater than 0 in the whole data set, not the range.

I'll post a better example below.

Book1.xlsx
ABCDE
110FirstLast
2207
330
440
550
660
771
885
997
101010
11115
12126
13130
14140
15150
16160
17170
18180
19190
20200
21218
222215
232336
24245
25250
26260
27270
28280
29290
30300
31318
32327
33330
34340
35350
Sheet4
Cell Formulas
RangeFormula
D2D2=INDEX(A1:A99998,MATCH(TRUE,INDEX(B:B>0,0),))
 
Upvote 0
How about
Fluff.xlsm
ABCDE
110FirstLast
220712
330
440
550
660
771
885
997
101010
11115
12126
13130
14140
15150
16160
17170
18180
19190
20200
21218
222215
232336
24245
25250
26260
27270
28280
29290
30300
31318
32327
33330
34340
35350
Sheet5
Cell Formulas
RangeFormula
D2:E2D2=LET(x,XLOOKUP(TRUE,B1:B1000>0,A1:A1000),HSTACK(x,INDEX(x:A1000,XMATCH(0,INDEX(B:B,ROW(x)):B1000)-1)))
Dynamic array formulas.
 
Upvote 0
Solution
One more option:

Excel Formula:
=LET(
col_1,A1:A35,
col_2,B1:B35,
a,SCAN(0,col_2,LAMBDA(x,y,IF(y=0,0,x+1))),
b,SCAN(0,a,LAMBDA(x,y,IF(y=1,x+1,x))),
c,IF(col_2=0,0,1),
d,b*c,
WRAPROWS(DROP(REDUCE("",DROP(UNIQUE(d),1),LAMBDA(a,b,VSTACK(a,TAKE(FILTER(col_1,d=b),{1,-1})))),1),2))
 
Upvote 0
That just returns #VALUE! for me.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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