title: Excel VBA: Loop through cells on another column basing on the first row
body: <p>I'm currently creating an automation that will separate the fruits for each store. Basically my file looks like below: </p>
  
  <p><a href="https://i.stack.imgur.com/clEcm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/clEcm.png" alt="enter image description here"></a></p>
  
  <p>What I need to do is to transfer all fruits of Store X and B to column F (all fruits from different stores). The number of stores could grow as well as the fruits.</p>
  
  <p>I have the code below, however, it only gets the first fruit and jump in to the next store already. </p>
  
  <pre><code>Sub test()
      Dim i, lastrow As Long
      lastrow = ActiveSheet.Cells(Worksheets(1).Rows.Count, "A").End(xlUp).Row 
  
      For i = 2 To lastrow
          Cells(i, 1).Select
  
          If Cells(i, 1).Value &lt;&gt; "" Then
              Cells(i, 6) = Cells(i, 4).Value
          End If
      Next i
  End Sub
  </code></pre>
  
  <p>I'm thinking to add another <code>lastrow</code> count for the fruits, however, it just continues until the last row of column D. </p>