title: Below Excel VBA function is only working for first IF condition, ELSEIF is not working
body: <p>Below Excel VBA function is only working for first <code>If</code> condition, <code>ElseIf</code> is not working.</p>
  <pre class="lang-vb prettyprint-override"><code>Function Alarms(L2) As String
      Set a = Application.WorksheetFunction
  
      If IsError(a.Find(&quot;HHH&quot;, L2, 1)) = False Then 
          Alarms = &quot;HHH HTRP&quot;
      ElseIf IsError(a.Find(&quot; HI&quot;, L2, 1)) &lt;&gt; True Then   
          Alarms = &quot;HI&quot;
      ElseIf IsError(a.Find(&quot;IOP&quot;, L2, 1)) = False Then   
          Alarms = &quot;IOP&quot;
      ElseIf IsError(a.Find(&quot;OOP&quot;, L2, 1)) = False Then    
          Alarms = &quot;OOP&quot;
      ElseIf IsError(a.Find(&quot;ANS&quot;, L2, 1)) = False Then    
          Alarms = &quot;ANS&quot;
      ElseIf IsError(a.Find(&quot; HH&quot;, L2, 1)) = False Then    
          Alarms = &quot;HH&quot;
      ElseIf IsError(a.Find(&quot;HTRP&quot;, L2, 1)) = False Then    
          Alarms = &quot;HHH HTRP&quot;
      ElseIf IsError(a.Find(&quot; LO&quot;, L2, 1)) = False Then    
          Alarms = &quot;LO&quot;
      ElseIf IsError(a.Find(&quot; LL&quot;, L2, 1)) = False Then    
          Alarms = &quot;LL&quot;
      ElseIf IsError(a.Find(&quot;LLL&quot;, L2, 1)) = False Then    
          Alarms = &quot;LLL LTRP&quot;
      ElseIf IsError(a.Find(&quot;LTRP&quot;, L2, 1)) = False Then    
          Alarms = &quot;LLL LTRP&quot;
      ElseIf IsError(a.Find(&quot;NR&quot;, L2, 1)) = False Then    
          Alarms = &quot;NR&quot;
      ElseIf IsError(a.Find(&quot;DV&quot;, L2, 1)) = False Then    
          Alarms = &quot;DV&quot;
      ElseIf IsError(a.Find(&quot;VEL&quot;, L2, 1)) = False Then    
          Alarms = &quot;VEL&quot;
      ElseIf IsError(a.Find(&quot;TRIP&quot;, L2, 1)) = False Then    
          Alarms = &quot;TRIP&quot;
      ElseIf IsError(a.Find(&quot;MHI&quot;, L2, 1)) = False Then    
          Alarms = &quot;MHI MLO&quot;
      ElseIf IsError(a.Find(&quot;MLO&quot;, L2, 1)) = False Then    
          Alarms = &quot;MHI MLO&quot;
      ElseIf IsError(a.Find(&quot;CERR&quot;, L2, 1)) = False Then    
          Alarms = &quot;CERR&quot;
      ElseIf IsError(a.Find(&quot;PERR&quot;, L2, 1)) = False Then    
          Alarms = &quot;PERR&quot;
      ElseIf IsError(a.Find(&quot;OVR&quot;, L2, 1)) = False Then   
          Alarms = &quot;OVR&quot;
      ElseIf IsError(a.Find(&quot;FAULT&quot;, L2, 1)) = False Then    
          Alarms = &quot;FAULT&quot;
      ElseIf IsError(a.Find(&quot;INT&quot;, L2, 1)) = False Then    
          Alarms = &quot;INT&quot;
      ElseIf IsError(a.Find(&quot;ALM&quot;, L2, 1)) = False Then    
          Alarms = &quot;ANN&quot;
      Else
          Alarms = &quot;-&quot;
      End If
  End Function
  </code></pre>