Thread: grouping rows
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
bduncan bduncan is offline
external usenet poster
 
Posts: 20
Default grouping rows

Thank you for the macro. It wasn't what I thought I was looking for. I was
looking for a way to group the part number with the serial numbers so that
when I sorted our part numbers the serial number would stay with the part
number. I thought grouping would do this but it appears I was mistaken on
that.

"Roger Govier" wrote:

Hi

If I understand your request correctly, then the following macro should
achieve what you want

Sub FillParts()
Dim lr As Long, i As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lr
If Cells(i, 2) = "" Then
Cells(i, 2) = Cells(i, 1)
Cells(i, 1) = Cells(i - 1, 1)
End If
Next i
End Sub

Copy code above
Alt+F11 to invoke VB Editor
InsertModule
Paste code into white pane that appears
Alt+F11 to rturn to Excel

To use
Alt+F8
Select macro FillPartsRun

--
Regards
Roger Govier

"bduncan" wrote in message
...
I export our inventory report into excel. In column A we have out serial
numbers and column B is our part numbers and column C is our quantity.
The
part number is only listed once in column B then in the rows below the
part
number in column A is the serial numbers for the part. Is there a vb
program
that could automatically highlight the serial numbers for a part number
and
group them together so that I can then manipulate my sheet with out
loosing
the serial numbers that go along with the part numbers?