title: Using a for loop to append to array in Excel VBA Basic
body: <p>How do I loop through a sheet using <code>IF</code> statements, and for each <code>TRUE</code>, append it to an array?</p>
  
  <p>Basic example, if <code>Cells(y, 1).Value</code> is greater than 0, then append 1 to an array and do so through the given range creating an array with multiple values of 1 (given multiple Cells(y, 1).Value(s) is greater than 0).</p>
  
  <p>This is how I've created loops before. </p>
  
  <pre><code>For y = 2 To LastRow
  
      On Error Resume Next
      If Cells(y, 1).Value &gt; 0 Then   
          Cells(y, 2).Value = 1     ' Instead of populating Cells(y,2) with "1" IF true, I want to append the value to an array
      ElseIf Cells(y, 1).Value = 0 &gt; 0 Then 
          Cells(y, 2).Value = 2
      Else
          Cells(y, 2).Value = 0
      End If
  
  Next y
  </code></pre>