Solver function in excel referencing VBA function -


i trying minimize using solver tool, in excel 2010,

abs(expectedpayout(h3,h6,h5,h7,h8,h4)-h21) 

where expectedpayout function created in vba. solver run, giving me nonsense answer. since expectedpayout created function, can solver not work this?

thanks

edit: adding more info

my data in form of a+bi, , b constants can manipulated, , doubles.

my goal try optimize , b, such difference between expectedpayout, , h21, close 0 possible

here code expectedpayout

function expectedpayout(age double, payment double, rate double, col double,  guaranteedtime integer, gender string)  dim discountfactor double dim expectedvalue double dim prob double  discountfactor = 1 / (1 + rate) expectedvalue = 0   = (age + guaranteedtime + 1) 115       'stochastic payments         prob = 1         each cell in range("b" & age + 3 & ":b" & + 3)             prob = prob * (1 - cell.value)         next         expectedvalue = expectedvalue + payment * ((1 + col) ^ (i - (age + 1))) * prob * (discountfactor ^ (i - age)) next  = 1 guaranteedtime                         'deterministic payments     expectedvalue = expectedvalue + payment * ((1 + col) ^ (i - 1)) * (discountfactor ^ i) next  expectedpayout = expectedvalue  end function 

solver not work user-defined functions. recommend rather create new function inverse of whatever expectedpayout calculates , use instead of solver.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -