title: VBA to create groups in Excel and then sort each group
body: <p>I have a list in excel of parts and when the were purchased.  The parts are listed in 4 rows.  The first row is a summary of all on-hand.  The next three rows represent how many are on-hand at each purchased price.  I have over 200 parts and I know how to manually group them, but am interested in writing the VBA code that will create a group for each change in Part No.  Then once grouped, within that group, I want to have the bottom 3 rows sorted from oldest to newest and if there are any blanks leaving them on the bottom of the group.</p>
  
  <pre><code>Part No.    Part Description    On-Hand  Price      Date      Ordered   Bol #   
  55 NIT            NC               21                   
  55 NIT            NC               10    15.00      09/18/13    15  115352-00
  55 NIT            NC               6     15.10      10/09/13    6   135216-00
  55 NIT            NC               5     15.05      11/17/13    5   156849-00  
  404 R             cooling          2                    
  404 R             cooling          1     112.00     08/29/13    2   147859-00
  404 R             cooling          1     102.82     09/18/13    1   159568-00
  404 R             cooling          0     102.82 
  </code></pre>
  
  <p>@ARich  This is what I have for the grouping.  I don't think it is the most efficient way of doing it, but it gets the job done for a known number of parts.  I am not sure how to code it to pick up all the data and run the loop until it has covered all rows.</p>
  
  <pre><code>Sub Makegroups4()
  
  '   create a group out of every 4 rows.  Skip the first row so it still shows and group the other three rows.
  '
  '   i will be used to identify 1st row in group
  
      i = 5
  
      For x = 1 To 175
  
          Rows(i &amp; ":" &amp; (i + 2)).Select
          Selection.Rows.Group
  
          i = i + 4
  
      Next
  
  
  
  End Sub
  </code></pre>