title: VBA - Split and IsError Function
body: <p>I'm struggling with VBA code. I'm working on a ID code generator program. One of the processes involves Split Company Names by words, and taking the first two words. Split has proved to be useful in this tasks, however, when in dealing with Company Names shorter than 2 words I've got a #VALUE! Error.</p>
  
  <p>One way I tried to fix it, was using the ISERROR function, so if I get any error it replaces it with a character, say "X".</p>
  
  <p>In summary, what I'm trying is to capture only the second Word of the Name, if there is no second Word, just display "X".</p>
  
  <pre><code>Public Function idcode_2(text As String) As String
  Dim Arr_text As Variant
  Dim rz_x, rz2, code As String
  Dim i As Integer
  Dim c
  Arr_text = Split(text, " ", 3)
  rz2 = Arr_text(1)
  If IsError(rz2) = True Then
      rz2 = "X"
     Else
      rz2 = rz2 &amp; ""
  End If
      idcode_2 = rz2
  End Function
  </code></pre>
  
  <p>I'm using VBA in Excel - Microsoft Office Professional Plus 2013.</p>