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