View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Calculating a growing formula

Hi. This will put it on the worksheet, and also in the immediate window.
Not sure what you have set up.
You can pull up the Immediate window in vba by hitting Ctrl+G
As a side note, because it's a function, you can use it on a worksheet also.
=SolveForM(A1)
Also note that this version is only good to about 8-9 digits, as Excel's
"GammaDist" function is only accurate to that many digits as well.
We note that (1+m+m²/2+m³/6+(m^4)/24)... is the Taylor expansion of Exp(m)
to your 'x terms. Solving with a m^30 term is hard, so that's why I
suggested this iterative approach.

Sub TestIt()
Dim x As Long
For x = 1 To 30
Cells(x, 1) = FormatNumber(SolveForM(x), 6)
Debug.Print x; ": "; FormatNumber(SolveForM(x), 6)
Next x
Columns("A:A").NumberFormat = "#0.000000"
End Sub

Function SolveForM(x)
Dim g As Double
Dim f As Double
Dim gd As Double
Dim j As Long

With WorksheetFunction
g = .Max(x, 0.001)
f = .Fact(x)
For j = 1 To 10
gd = .GammaDist(g, x + 1, 1, True) - 0.05
g = g - (Exp(g) * .Power(g, -x) * gd * f)
Next j
End With
SolveForM = g
End Function

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"bambinos83" wrote
in message ...

Thanks for your time Dana.

A few questions though. On your last post, you sent another form of
"SolveForM(x) Function". This one can replace the other one in the
entire code I assume?

I looked at it and when I run it, the results are not printed anywhere.
I was wondering how I to know if it really worked. Thanks again.


--
bambinos83
------------------------------------------------------------------------
bambinos83's Profile:
http://www.excelforum.com/member.php...o&userid=32589
View this thread: http://www.excelforum.com/showthread...hreadid=556589