+ Reply to Thread
Results 1 to 7 of 7

Elseif function error

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Cape Town
    MS-Off Ver
    Excel 2010
    Posts
    107

    Elseif function error

    Hi,

    I've created a simple function but it doesn't seem to work. Any help would be greatly appreciated.

    HTML Code: 
    Thanks a million!
    Last edited by concatch; 12-06-2012 at 10:22 AM.

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

    Re: Elseif function error

    Function getelasticity(rng As Range) As String
        Dim strReturn As String
    
        If rng.Value = 0 Then 
           strReturn = "Perfectly Inelastic Demand"
        ElseIf rng.Value > -1 And rng.Value < 0 Then
            strReturn = "Inelastic Demand"
        ElseIf rng.Value = -1 Then 
           strReturn = "Unit Elastic Demand"
        ElseIf rng.Value > -9999 And rng.Value < -1 Then 
           strReturn = "Elastic Demand"
        ElseIf rng.Value < -9999 Then 
           strReturn = "Perfectly Elastic"
        Else
     strReturn = "UNKNOWN"
        End If
        getelasticity = strReturn
    End Function
    Last edited by JosephP; 12-06-2012 at 10:17 AM.
    Josie

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

  3. #3
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Cape Town
    MS-Off Ver
    Excel 2010
    Posts
    107

    Re: Elseif function error

    Thanks a million!!!

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Elseif function error

    I do not see any error on the function

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Elseif function error

    Jay,
    No code tags

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

    Re: Elseif function error

    sure there are ;-)

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Elseif function error

    You need to check out If-Then-Else syntax: http://www.techonthenet.com/excel/formulas/if_then.php

    and don't forget to assign the value of the string variable to your function at the end!

    Edit: sorry, a bit slow.

+ 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