+ Reply to Thread
Results 1 to 5 of 5

VBA code returns "0" and no other number

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

    VBA code returns "0" and no other number

    I am working on a VBA code that will return a value (temperature or pressure) given three inputs: refrigerant selection, temperature or pressure, and the input cell. I keep getting a return of zero no matter the inputs (the equations have been verified as correct). Below is my code and please help if possible.

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 07-10-2013 at 06:05 PM. Reason: As per Forum Rule #3, please use code tags…Thanks.

  2. #2
    Registered User
    Join Date
    01-14-2013
    Location
    somewhere. in a building.
    MS-Off Ver
    Excel 2003
    Posts
    4

    re: VBA code returns "0" and no other number

    This is a shot in the dark (I don't know the rest of your code), but I'm guessing you don't have variables named 'R717', 'R22'... and 'T' and 'P' If you don't, then put double quotes (") around each of those values and see what happens.

    Or better yet, put Option Explicit at the top of your module, and see if you get a bunch of compile errors.

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

    re: VBA code returns "0" and no other number

    Well I wanted those inputs to be typed in by the user, meaning, they choose which refrigerant and then the program performs the calculation. Is this allowed? And thank you for your help

  4. #4
    Registered User
    Join Date
    01-14-2013
    Location
    somewhere. in a building.
    MS-Off Ver
    Excel 2003
    Posts
    4

    re: VBA code returns "0" and no other number

    Oh, it's definitely allowed for a user to enter inputs. Try replacing your function with this one.
    Please Login or Register  to view this content.
    As your code was written, (provided that option explicit wasn't included at the top of the module) all those Rx's, T and P were considered to be variables that initialize to "" (empty string). I have a feeling that if you entered empty strings for the first 2 inputs you'd get the result you'd expect for R717 and T.

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

    re: VBA code returns "0" and no other number

    That worked! Thank you sooo much!

+ 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