Extract a range of values

BigBeachBananas

Active Member
Joined
Jul 13, 2021
Messages
450
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi all,

I have the following sample data. I have determined the number of usable months for my data in cell G2. Now, I need help extracting the usable months' value from columns D to E (highlighted in yellow). Essentially, it should be the last non-zero value in the Count Column (Column C), counting up to # of usable months (in this case 25). Let me know if this is unclear.

Excel question.xlsx
ABCDEFG
1MonthClaimsCountRolling 12 Months AverageValues to Use
21$00Months to use25
32$00
43$00
54$00
65$00
76$00
87$00
98$00
109$00
1110$00
1211$00
1312$00#DIV/0!
1413$00#DIV/0!
1514$00#DIV/0!
1615$00#DIV/0!
1716$00#DIV/0!
1817$00#DIV/0!
1918$00#DIV/0!
2019$891,5431570$567.86
2120$775,3181576$529.84
2221########1583$577.71
2322$997,8111577$591.47
2423$999,9281580$599.76
2524########1576$611.70
2625$949,8051591$609.59
2726$775,7971582$594.66
2827########1595$625.16
2928########1598$660.68
3029########1603$672.46
3130########1598$698.61
3231########1606$710.88
3332########1622$740.38
3433$888,1671621$729.67
3534########1624$744.11
3635########1632$778.88
3736########1625$791.12
3837########1652$797.95
3938########1671$810.85
4039########1676$815.76
4140########1689$798.80
4241########1707$817.86
4342########1701$821.09
4443########1722$820.74
4544########1740$820.93
4645########1775$846.20
4746########1798$845.88
4847########1799$832.41
4948########1799$845.78
5049########2061$909.88
5150########2073$935.70
5251########2080$936.90
5352########2079$938.26
5453########2082$918.43
5554########2072$899.64
5655$00$914.17
5756$00$920.20
5857$00$926.24
5958$00$939.67
6059$00$947.95
6160$00$944.02
Sheet1
Cell Formulas
RangeFormula
G2G2=COUNTIF(C2:C61,">0")-11
D13:D61D13=SUM(B2:B13)/SUM(C2:C13)
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
please repost your mini worksheet with the column widths wide enough to display values.
also, can you provide a sample of expected values in the cells you want to see the data in?
 
Upvote 0
please repost your mini worksheet with the column widths wide enough to display values.
also, can you provide a sample of expected values in the cells you want to see the data in?
Excel question.xlsx
ABCDEFG
1MonthClaimsCountRolling 12 Months AverageValues to UseMonths to use
21$00$ 698.6125
32$00$ 710.88
43$00$ 740.38
54$00$ 729.67
65$00$ 744.11
76$00$ 778.88
87$00$ 791.12
98$00$ 797.95
109$00$ 810.85
1110$00$ 815.76
1211$00$ 798.80
1312$00#DIV/0!$ 817.86
1413$00#DIV/0!$ 821.09
1514$00#DIV/0!$ 820.74
1615$00#DIV/0!$ 820.93
1716$00#DIV/0!$ 846.20
1817$00#DIV/0!$ 845.88
1918$00#DIV/0!$ 832.41
2019$891,5431570$567.86$ 845.78
2120$775,3181576$529.84$ 909.88
2221$1,065,1371583$577.71$ 935.70
2322$997,8111577$591.47$ 936.90
2423$999,9281580$599.76$ 938.26
2524$1,058,2091576$611.70$ 918.43
2625$949,8051591$609.59$ 899.64
2726$775,7971582$594.66
2827$1,382,5081595$625.16
2928$1,561,1561598$660.68
3029$1,264,4921603$672.46
3130$1,572,1361598$698.61
3231$1,150,5401606$710.88
3332$1,371,8381622$740.38
3433$888,1671621$729.67
3534$1,309,2641624$744.11
3635$1,708,0641632$778.88
3736$1,332,4421625$791.12
3837$1,130,3111652$797.95
3938$1,097,6421671$810.85
4039$1,544,1201676$815.76
4140$1,302,7151689$798.80
4241$1,723,4011707$817.86
4342$1,720,5101701$821.09
4443$1,238,6861722$820.74
4544$1,472,4721740$820.93
4645$1,525,5411775$846.20
4746$1,449,9191798$845.88
4847$1,572,4521799$832.41
4948$1,754,3091799$845.78
5049$2,831,1772061$909.88
5150$2,019,7802073$935.70
5251$1,948,3352080$936.90
5352$1,698,5022079$938.26
5453$1,624,8532082$918.43
5554$1,627,5582072$899.64
5655$00$914.17
5756$00$920.20
5857$00$926.24
5958$00$939.67
6059$00$947.95
6160$00$944.02
Sheet1
Cell Formulas
RangeFormula
G2G2=COUNTIF(C2:C61,">0")-11
D13:D61D13=SUM(B2:B13)/SUM(C2:C13)
 
Upvote 0
Thanks, try this. I hope this is what your want.

Mr excel questions 58.xlsm
ABCDEFG
1MonthClaimsCountRolling 12 Months AverageValues to Use
210.000778.88Months to use25
320.000791.12
430.000797.95
540.000810.85
650.000815.76
760.000798.80
870.000817.86
980.000821.09
1090.000820.74
11100.000820.93
12110.000846.20
13120.000 845.88
14130.000 832.41
15140.000 845.78
16150.000 909.88
17160.000 935.70
18170.000 936.90
19180.000 938.26
2019891,543.481,570567.86918.43
2120775,317.761,576529.84899.64
22211,065,137.311,583577.71914.17
2322997,810.631,577591.47920.20
2423999,928.331,580599.76926.24
25241,058,209.301,576611.70939.67
2625949,804.651,591609.59947.95
2726775,796.511,582594.66944.02
28271,382,508.041,595625.16
29281,561,156.351,598660.68
30291,264,491.851,603672.46
31301,572,136.141,598698.61
32311,150,540.111,606710.88
33321,371,838.301,622740.38
3433888,167.001,621729.67
35341,309,264.061,624744.11
36351,708,063.991,632778.88
37361,332,442.401,625791.12
38371,130,311.411,652797.95
39381,097,642.081,671810.85
40391,544,119.811,676815.76
41401,302,715.391,689798.80
42411,723,400.941,707817.86
43421,720,509.521,701821.09
44431,238,686.221,722820.74
45441,472,471.911,740820.93
46451,525,541.111,775846.20
47461,449,919.081,798845.88
48471,572,451.841,799832.41
49481,754,309.131,799845.78
50492,831,177.042,061909.88
51502,019,780.402,073935.70
52511,948,334.762,080936.90
53521,698,502.042,079938.26
54531,624,852.782,082918.43
55541,627,558.162,072899.64
56550.000914.17
57560.000920.20
58570.000926.24
59580.000939.67
60590.000947.95
61600.000944.02
BigBeachBananas
Cell Formulas
RangeFormula
E2:E27E2=INDEX($D$2:$D$61,MAX(($A$2:$A$61)*($D$2:$D$61>0))-25):INDEX($D$2:$D$61,MAX(($A$2:$A$61)*($D$2:$D$61>0)))
G2G2=COUNTIF(C2:C61,">0")-11
D13:D61D13=IF(SUM(C2:C13)=0,"",SUM(B2:B13)/SUM(C2:C13))
Dynamic array formulas.
 
Upvote 0
How about
Excel Formula:
=CHOOSEROWS(D2:D100,SEQUENCE(G2,,XMATCH(TRUE,(C1:C100<>0),,-1)-G2))
 
Upvote 0
Solution
Thanks, try this. I hope this is what your want.

Mr excel questions 58.xlsm
ABCDEFG
1MonthClaimsCountRolling 12 Months AverageValues to Use
210.000778.88Months to use25
320.000791.12
430.000797.95
540.000810.85
650.000815.76
760.000798.80
870.000817.86
980.000821.09
1090.000820.74
11100.000820.93
12110.000846.20
13120.000 845.88
14130.000 832.41
15140.000 845.78
16150.000 909.88
17160.000 935.70
18170.000 936.90
19180.000 938.26
2019891,543.481,570567.86918.43
2120775,317.761,576529.84899.64
22211,065,137.311,583577.71914.17
2322997,810.631,577591.47920.20
2423999,928.331,580599.76926.24
25241,058,209.301,576611.70939.67
2625949,804.651,591609.59947.95
2726775,796.511,582594.66944.02
28271,382,508.041,595625.16
29281,561,156.351,598660.68
30291,264,491.851,603672.46
31301,572,136.141,598698.61
32311,150,540.111,606710.88
33321,371,838.301,622740.38
3433888,167.001,621729.67
35341,309,264.061,624744.11
36351,708,063.991,632778.88
37361,332,442.401,625791.12
38371,130,311.411,652797.95
39381,097,642.081,671810.85
40391,544,119.811,676815.76
41401,302,715.391,689798.80
42411,723,400.941,707817.86
43421,720,509.521,701821.09
44431,238,686.221,722820.74
45441,472,471.911,740820.93
46451,525,541.111,775846.20
47461,449,919.081,798845.88
48471,572,451.841,799832.41
49481,754,309.131,799845.78
50492,831,177.042,061909.88
51502,019,780.402,073935.70
52511,948,334.762,080936.90
53521,698,502.042,079938.26
54531,624,852.782,082918.43
55541,627,558.162,072899.64
56550.000914.17
57560.000920.20
58570.000926.24
59580.000939.67
60590.000947.95
61600.000944.02
BigBeachBananas
Cell Formulas
RangeFormula
E2:E27E2=INDEX($D$2:$D$61,MAX(($A$2:$A$61)*($D$2:$D$61>0))-25):INDEX($D$2:$D$61,MAX(($A$2:$A$61)*($D$2:$D$61>0)))
G2G2=COUNTIF(C2:C61,">0")-11
D13:D61D13=IF(SUM(C2:C13)=0,"",SUM(B2:B13)/SUM(C2:C13))
Dynamic array formulas.
Yes, this is what I want but Fluff's answer is more comprehensible for me. Appreciate the time.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Yes, this is what I want but Fluff's answer is more comprehensible for me. Appreciate the time.
Yes, it is a very elegant solution. If your users all have 365 version functions it works well. If this is shared with other users that have earlier versions of excel it may not work.
 
Upvote 0
Your formula will not work with 2019 or earlier as it uses a spill range. ;)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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