title: Handle Error 9 when there is an Empty Array
body: <p>I am writing a script that will loop through an Excel spreadsheet and find if there are duplicates of selected cells.  If there are duplicates then the function will return an array of which rows are duplicates and create a comment to tell me the rows.</p>
  
  <p>I have been able to handle error 0 but now I am getting error 9 when I check if there are elements in the array using the UBound function.</p>
  
  <p>How do I validate if the array of integers is empty?</p>
  
  <pre><code>Function IsArrayEmpty(anArray As Variant) As Boolean
      Dim i As Integer
  
      On Error Resume Next
          i = UBound(anArray, 1)
      Select Case (Err.Number)
          Case 0
              IsArrayEmpty = True
          Case 9
              IsArrayEmpty = True
          Case Else
              IsArrayEmpty = False
      End Select
  End Function
  </code></pre>