title: Loop compares values in a column and inserts new row if different but ignores the first row if it's a unique value
body: <p>I'm sorting an inventory page and separating the sizes after it's sorted to make it easier to read.</p>
  
  <p>If the top row has a unique value (there's just one line of that item) then it wont insert a row after it and instead groups it with the next group of values.</p>
  
  <p>If there's more than 1 row with that top value then it inserts a row properly after that group.</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
  ' sort by size then length
  With ActiveSheet.Sort
      .SortFields.Clear
      .SortFields.Add Key:=Selection.Columns(3), Order:=xlDescending
      .SortFields.Add Key:=Selection.Columns(4), Order:=xlDescending
      .SetRange Selection
      .Apply
  End With
  
  
  ' insert rows between sizes
  Dim iRow As Integer, iCol As Integer
  Dim oRng As Range
  
  Set oRng = Range("D9")
  
  iRow = oRng.Row
  iCol = oRng.Column
  
  Do
  If Cells(iRow + 1, iCol) &lt;&gt; Cells(iRow, iCol) Then
     Cells(iRow + 1, iCol).EntireRow.Insert shift = xlDown
     iRow = iRow + 2
  Else
     iRow = iRow + 1
  End If
  
  Loop While Not Cells(iRow, iCol).Text = ""
  
  End Sub
  </code></pre>
  
  <p>It ends up looking like this: <a href="https://i.imgur.com/AfYXbuF.png" rel="nofollow noreferrer">https://i.imgur.com/AfYXbuF.png</a></p>
  
  <p>How do I get it to insert a row after that top value?</p>