title: Empty array at the end of the loop VBA Excel
body: <p>I have the below code that adds values to an array if it meets a criteria.</p>
  
  <p>It keeps looping horizontally through the columns across a row and then repeats the same for the next row and so on.</p>
  
  <p>I am trying to clear the values accumulated in the array and empty it at the end of the columns loop:</p>
  
  <pre><code>For a = 21 To 23
  
      Count = 0
      For b = 2 To 36
      If Not Worksheets("Sheet1").Cells(a, b).Value = "A" And Not Worksheets("Sheet1").Cells(a, b).Value = "B" Then
      Count = Count + 1
      Else
      If Not Count = 0 Then
  
      Dim arr() As Long
  
      arrLen = 1
      ReDim Preserve arr(1 To arrLen)
      arr(arrLen) = Count
      arrLen = arrLen + 1
  
      For i = LBound(arr) To UBound(arr)
          msg = msg &amp; arr(i) &amp; vbNewLine
      Next i
  
      Count = 0
      End If
      End If
      Next b
  
      MsgBox Worksheets("Sheet1").Cells(a, 1).Value &amp; vbNewLine &amp; msg
      Erase arr 'not working
  
  Next a
  </code></pre>
  
  <p>As you can see from the above code, I get a msgbox displaying the values at the end of each loop, however as it continues, the array keeps getting bigger and bigger indicating that the Erase line is not working.</p>
  
  <p>Kindly help!</p>