Consulting

Results 1 to 9 of 9

Thread: How to do loop in the function?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Feb 2018
    Posts
    4
    Location

    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. (



    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
    Last edited by Paul_Hossler; 02-18-2018 at 07:32 AM. Reason: Added CODE tags and moved outside of TextBox

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •