• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro that solves for closest result rather than the result that

BSmith

New Member
I am trying to write a macro that can solve for a value that is the closest to a pre-dertermined value. I am unable to solve for the exact amount because I am dealing with a specific number of payments to achieve a desired yield. I am only able to have whole payments (not partial). Is there anything I can incorporate into the macro to solve for the whole value that is the closest to the value I am solving for? Also, is there any way to make sure the whole value that is closest to this value is greater than the value?


Specifically - I have a 12 month payment stream. The yield I need to achieve is X. Certain variables can change the payment structure for the 12 months, and I need to be able to hit a button that will solve the number of payments it will take for the yield to be greater than or equal to X. Obviously, I want the value that is closest to X as well.
 
Have a look at

http://www.dailydoseofexcel.com/archives/2005/10/27/which-numbers-sum-to-target/

or

http://www.dailydoseofexcel.com/archives/2004/06/23/ugly-formulas/

(the entry by Lori near the bottom)
 
Back
Top