View Single Post
  #6   Report Post  
hamster
 
Posts: n/a
Default Need to Concatenate


Thanks Phil! This really helps since I was going to have code this. This
will save a lot of time for similar queries....

Only problem is the first line doesn't work out... but we changed it
slightly to this... what do you think?

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

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
sTemp = Range("A1").Value & Range("B1").Value
iStart = 1
For i = 2 To iLastRow
If Cells(i, "A").Value & Cells(i, "B").Value = sTemp Then
Cells(iStart, "C").Value = Cells(iStart, "C").Value & _
", " & Cells(i, "C").Value
If rng Is Nothing Then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
Else
sTemp = Cells(i, "A").Value & Cells(i, "B").Value
iStart = i
End If
Next i

If Not rng Is Nothing Then
rng.Delete
Set rng = Nothing
End If


End Sub


--
hamster
------------------------------------------------------------------------
hamster's Profile: http://www.excelforum.com/member.php...o&userid=28706
View this thread: http://www.excelforum.com/showthread...hreadid=483903