How to do loop in the function?
I am trying to create a function however unable to progress as i'm stuck with the iteration part. Below are my codes. How do i go about creating the loop? I have tried many options but to no avail. At times, the system stalled on me. :((
|
|
Code:
Function TADegC(DEN, Temp As Double)
Application.Volatile
T15 = temp - 15
RHO = DEN
RH15 = RHO * 1000
Do
RH15 = RHO15
K0 = 613.9723
K1 = 0
A = 0
alpha15 = (K0 / (RH15 ^ 2)) + (K1 / RH15) + A
VCF15 = Exp((-alpha15 * T15) * (1 + 0.8 * alpha15 * T15))
rho15 = RH15 / VCF15
Error = Abs(rho15 - RH15)
Loop until error <= 0.05
TADegC = rho15
End Function