+ Reply to Thread
Results 1 to 3 of 3

Defined Function: Compile Error Block If without End If

  1. #1
    Forum Contributor
    Join Date
    06-06-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    180

    Defined Function: Compile Error Block If without End If

    Hi all,

    I have created the following defined function in excel VBA but i get the complie error:-

    'Block if without end if'

    This this the code I have written for the function:-

    Public Function Rule_45(Current, Previous, Result)

    ' RED: 'Decreasing Trend' OR 'Same' AMBER:'Increasing Trend' GREEN:'>83%'
    If Result = "-" Then
    Rule_45 = "-"
    ElseIf Result > 0.77 Then
    Rule_45 = "G"
    ElseIf Current > Previous Then
    Rule_45 = "A"
    ElseIf Current < Previous Then
    Rule_45 = "R"
    If Current = Previous Then
    Rule_45 = "R"
    End If
    End Function

    Any help would be appreciated!

    Regards,

    Forrestgump

  2. #2
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Defined Function: Compile Error Block If without End If

    insert an End If before "If Current = Previous Then"
    Click on the star if you think I helped you

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Defined Function: Compile Error Block If without End If

    You must change:
    Please Login or Register  to view this content.
    for:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Compile error: Sub or function not defined?
    By mdovey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2013, 02:57 PM
  2. [SOLVED] Compile error: sub or function not defined
    By Anita7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2012, 08:50 PM
  3. compile error: sub or function not defined
    By eaglefana101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-17-2012, 01:18 AM
  4. Compile error: Sub or Function not defined
    By Nanga in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-23-2011, 11:05 AM
  5. Compile Error: Sub or Function not defined
    By johnmerlino in forum Excel General
    Replies: 3
    Last Post: 10-03-2010, 03:50 PM

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