combining row information

  • Thread starter Thread starter tgoosed
  • Start date Start date
T

tgoosed

I'm having an issue with an easy way to combine row information. Belo
is an example of the both the data and what I would like as an en
result. The spreadsheet I have contains over 37000 lines.

column a column b column c column d

1234 glove ea 04661
1234 glove ea 01661
1234 glove ea 06661
1235 mask ea 04661
1235 mask ea 01661

The output I would like would be
column a column b column c column d column e column f

1234 glove ea 04661 01661
06661
1235 mask ea 04661 0166
 
Here's a macro to do it

Sub Test()
Dim iLastRow As Long
Dim i As Long
Dim rng As Range

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 2 Step -1
If Cells(i, "A").Value = Cells(i - 1, "A").Value Then
Cells(i, "D").Resize(, 252).Copy Cells(i - 1, "E")
If rng Is Nothing Then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
End If
Next i

If Not rng Is Nothing Then rng.Delete

End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top