title: Combine rows where duplicate values exist in one column
body: <p>I need help combining rows with VBA in Excel dynamically where the value is sometimes the same in one column. </p>
  
  <p>Sample Data</p>
  
  <pre><code>A B C   D   E
  1 r 10  5   3
  1 r 12  8   2
  2 q 60  50  40
  2 q 25  45  55
  2 q 100 200 300
  </code></pre>
  
  <p>EDIT: mistake in my sample data, changed last value in A from 3 to 2.</p>
  
  <p>Ideally, I would combine the rows where the value is the same below in column <code>B</code> and while combining the values in C &amp; D separated by semi colon and summing the values in column E.</p>
  
  <p>It works when there is one duplicate, but not varying numbers of duplicates (dynamic combining)</p>
  
  <p>Here is basically what I have tried:</p>
  
  <pre><code>Dim i As Long
  i = 2
  
  For i = 2 to lastRow
      If Cells(i, 2).Value = Cells(i + 1, 2).Value Then
          Cells(i, 3).Value = Cells(i, 3).Value &amp; ";" &amp; Cells(i + 1, 3).Value
          Cells(i, 4).Value = Cells(i, 4).Value + Cells(i + 1, 4).Value
          Rows(i + 1).Delete
      Else
          i = i + 1
      End If
  Loop    
  </code></pre>