+ Reply to Thread
Results 1 to 8 of 8

#VALUE! error

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    7

    #VALUE! error

    Hello All,

    I am writing a code to get wet bulb temperature from dry bulb and relative humidity, but when I run my UDF, I am getting a #VALUE! error. I can't figure what parameters I should be setting to the correct data type as the are all numerical values. Any help is much appreciated.


    '-------------------------------------------------------------------------------
    'Calculate wet bulb temp given dry bulb temp and relative humidity
    '
    Function psychro_WBT(DBT, RH)
    '
    DBT = Dry_Bulb_°F
    DBR = DBT + 459.67
    c8 = -10440.397
    c9 = -11.29465
    c10 = -0.027022355
    C11 = 0.00001289036
    C12 = -2.4780681E-09
    C13 = 6.5459673

    Pws = Exp(c8 / DBR + c9 + c10 * DBR + C11 * DBR ^ 2 + C12 * DBR ^ 3 + C13 * Log(DBR))
    Ws = 0.621945 * Pws / (14.7 - Pws)
    Wact = RH * Pws

    Do
    WBT = DBR
    Wnew = ((1093 - 0.556 * WBT) * Ws - 0.24 * (DBR - WBT)) / (1093 + 0.444 * DBR - WBT)
    End
    WBT = WBT - 0.1
    Diff = (Wact - Wnew) / ((Wnew + Wact) / 2)
    Loop Until Diff < 0.01

    psychro_WBT = WBT

    End Function

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: #VALUE! error

    What is the purpose of this line?

    DBT = Dry_Bulb_°F

    You should also seriously consider declaring your variables

  3. #3
    Registered User
    Join Date
    07-10-2013
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: #VALUE! error

    Thanks that is a useless line. To declare variable is it just designating them with Dim BLAH As DataType?

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: #VALUE! error

    Why do you have "End" in your loop? That will stop everything after that. The loop is flawed. Not sure what you are actually trying to do.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: #VALUE! error

    ....and why do you need a UDF? Is an approximation which doesn't require an iterative approach an option in which case you could use standard Excel functions, in some intermediate helper columns if necessary?

    Explain the formula that links WBT to DBT and relative humidity in narrative form if necessary and maybe we can assist further.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Registered User
    Join Date
    07-10-2013
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: #VALUE! error

    Thank you everyone for your help.

    The End was to end the do command just because I thought I needed it. Overall, the UDF is to take the thousands of DBT and RH data points, and get other values from the psychrometric chart to perform further calculations. Because we do several of these analyses a week, it would be convenient to have a function to get the desired values.

    Thanks again, and here is my current code:
    Please Login or Register  to view this content.
    Last edited by arlu1201; 01-30-2014 at 01:27 AM.

  7. #7
    Registered User
    Join Date
    01-29-2014
    Location
    Oklahoma City
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: #VALUE! error

    Phillip Maddi,
    I am new for coding in VBA, and I came across your feed. I tried using you above mentioned code and was not able to get the right answer as the iteration stops right after 1st step. Please let me know if you had done something different which I was not able to catch.

    Thanks,
    Atul

  8. #8
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: #VALUE! error

    Good morning Atul. Please do not ressurect a 6 month old post. If you have a question please start a new thread as it is more likely to get an answer that way.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1