+ Reply to Thread
Results 1 to 10 of 10

#Value error in Excel Public Function

  1. #1
    Registered User
    Join Date
    07-16-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    5

    #Value error in Excel Public Function

    Good Afternoon,

    I keep getting the #Value! result using the syntax below. I'm new to writing user defined functions so the solution is not easy for me. Please help.

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 07-17-2012 at 03:16 AM. Reason: Added Code Tags

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel Public Functions

    last line should be
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Contributor
    Join Date
    10-07-2011
    Location
    Plano, TX USA
    MS-Off Ver
    Excel 2013
    Posts
    141

    Re: Excel Public Functions

    Welcome -

    You need to declare Ret

    Please Login or Register  to view this content.
    Also, you need to embed you code on the post as code or the Moderator Cops will bust you. Explained in the rules. http://www.excelforum.com/forum-rule...rum-rules.html
    Last edited by stubbsj; 07-16-2012 at 04:23 PM.

  4. #4
    Registered User
    Join Date
    07-16-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Excel Public Functions

    I tried both of those suggestions and received the same result. Month 1 and Month 2 are numbers and SvcDescr is text. The first line is to see if SvcDescr is a certain value "Filter/Block" then see if month2 is either greater than 17 but less than or equal to 29. If both are true, then do the calculation and if not true go to the Else statements.

    I have a simple table setup to test the function. A1 = Service Description B1 = Month 1 c1 = Month 2 d1 = month 3 and e1 = FORECAST
    A2 = Filter/Block B2 = 47 C2 = 17 D2 = 17 and E2 is where the function result is expected.


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-07-2011
    Location
    Plano, TX USA
    MS-Off Ver
    Excel 2013
    Posts
    141

    Re: Excel Public Functions

    Try
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-07-2011
    Location
    Plano, TX USA
    MS-Off Ver
    Excel 2013
    Posts
    141

    Re: Excel Public Functions

    This should work. You can't use FORECAST because it is an Excel Formula. You need to create a private function. Also, why are you passing Month1 but never use it in your function?

    Please Login or Register  to view this content.
    Last edited by stubbsj; 07-16-2012 at 05:04 PM.

  7. #7
    Registered User
    Join Date
    07-16-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    5

    Smile Re: Excel Public Functions

    Thanks I'll give it a try when I get into the office tomorrow. I use month 1 by adding it in at the end of the final expression....12 * 11 + Month1

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel Public Functions

    or perhaps
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-16-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Excel Public Functions

    Thanks...both of the suggestions work and now I want to throw a new wrinkle in...Instead of multiplying by "29", "17" or "12"...I want to multiply the average of month2 and month3 by 11 and add back in month 1.

    I have a simple table setup to test the function. A1 = Service Description B1 = Month 1 c1 = Month 2 d1 = month 3 and e1 = FORECAST
    A2 = Block/Filter B2 = 47 C2 = 10 D2 = 20 and E2 is where the function result is expected.

    ORIGINAL CODE

    Please Login or Register  to view this content.
    Or this code
    Please Login or Register  to view this content.
    Last edited by waholtmn; 07-17-2012 at 10:44 AM. Reason: removed unncessary text

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: #Value error in Excel Public Function

    I reckon
    Please Login or Register  to view this content.

+ 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