title: Visual Basic: Run-time error '9': "Subscript out of range"
body: <p>I'm trying to make a script, that can remove duplicates in a list of numbers. Only problem, is I keep getting <code>Subscript out of range (Error 9)</code>. </p>
  
  <pre><code>Sub remDupes()
  Dim units() As Variant
  For i = 2 To 37
      Dim var As String
      If ((Not Not units) = 0) Then
          For x = 0 To 36
              var = Cells(i, 22).Value
              If (units(x) = var) Then
                  Range("V" &amp; i, "AA" &amp; i).Value = ""
              Else
                  units(x) = var
              End If
          Next
      End If
  Next
  End Sub
  </code></pre>
  
  <p>The errors occurs at:</p>
  
  <pre><code>If (units(x) = var) Then
  </code></pre>
  
  <p>And I am not sure why</p>