min, match, offset problem

seanh1016

Active Member
Joined
Feb 16, 2003
Messages
254
I have two columns, column A=months, column B=values. Column B has some negative values in it. How do I find the closest value to zero in column B, then figure out which month this value occurs?

I don't want the lowest number -- just the one closest to zero. Would the min function still work here?

Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
seanh1016 said:
Book12
ABCDE
18MonthBegBalClosestto
19000
2011808.6291.13
2121670.6613
2231531.78
2341391.98
2451251.25
2561109.58
267966.97
278823.41
289678.89
2910533.41
3011386.96
3112239.54
321391.13
3314-58.26
3415-208.65
3516-360.04
3617-512.44
3718-665.85
3819-820.28
3920-975.74
Sheet1


Formulas...

E20:

=INDEX(B20:B39,MATCH(MIN(IF(B20:B39-E19>=0,B20:B39)),IF(B20:B39-E19>=0,B20:B39),0))

which must be confirmed with control+shift+enter instead of just with enter.

E21:

=INDEX(A20:A39,MATCH(E20,B20:B39,0))
 
Upvote 0
Another approach is to use one of the built-in financial functions, NPER(). Given your data, it appears that:

=NPER(D12,-D16,E19)

will return the number you are after, since the form of the function is

=NPER(Rate,Pmt,Pv,Fv,Type)

and you know the 3 arguments necessary to solve for the number of periods. Namely, you know the interest rate, the payment, and the present value (initial principal balance), which are constant in your example. Note that the last 2 arguments for this function are optional. That is, if they are omitted, they are assumed to be 0.

Finally, the CEILING function will round up the answer provided by NPER, since it doesn't always return a whole number. So, the final form would be:

=CEILING(NPER(D12,-D16,E19),1)

--Tom
 
Upvote 0
Aladin, yours works great. I combined both formulas to make one formula so I didn't have to do two steps. I came up with:

=INDEX(A20:A79,MATCH(INDEX(B20:B39,MATCH(MIN(IF(B20:B39-A19>=0,B20:B39)),IF(B20:B39-A19>=0,B20:B39),0)),B20:B79,0))

works great.

Tom, yours is good. But doesn't work in this case b/c it only factors in the rate, pmt, and pv -- and doesn't factor in if I were to pay more in a random month(which should decrease the payoff months). Aladin's solution simply looks at the months and the beginning balance.
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

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