Elseif Statement in excel VBA

The Else if statement is used to execute one code from multiple conditions. It is a chain of if…elseif statements in which each if statement is associated with elseif statement and last would be an else statement.

Syntax:-

If (condition) then
statement
Elseif (condition) then
statement
Elseif (condition) then
statement
Else
statement
End if

For Example

Sub if_elseif()
If Range(\”b2\”).Value <= 35 Then
Range(\”c2\”).Value = \”fail\”
ElseIf Range(\”b2\”).Value <= 60 Then
Range(\”c2\”).Value = \”pass\”
ElseIf Range(\”b2\”).Value <= 80 Then
Range(\”c2\”).Value = \”b grade\”
Else
Range(\”c2\”).Value = \”A grade\”
End If
End Sub