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

a = Cells(1, 2)

Hi. Glad it's working! Just want to point out something, as I'm not sure
of your data in B1.
If I put 0.95 into B1, I don't get the same answers as your test data.
I think you meant to use the following
a = 1 - Cells(1, 2)

With the above change, it works as expected. However, you data in B1 may
already be set up for this.
Again, just pointing it out.

As a side note, with x equal to 110, using factorial is a large number.
However, the final answer is still pretty good. The final answer appears to
be accurate to about 6-7 digits. Not too bad for such large numbers & using
Excel's "GammaDist" function.
--
Dana DeLouis
Windows XP, Office 2003


"bambinos83" wrote
in message ...

Thanks once again. I think you didn't get what I was saying but it
doesn't matter, I fixed it. It was really easy in fact!! So here is the
final code. I must thank you once again for all you've done on this
one.

Sub TestIt()
Dim x As Long
For x = 0 To 110
Cells(x + 4, 1) = FormatNumber(SolveForM(x), 6)
Debug.Print x; ": "; FormatNumber(SolveForM(x), 6)
Next x
Range("A1:A40").NumberFormat = "#0.000000"
End Sub

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

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


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