Blue_Bunny
04-04-2008, 07:43 AM
I have two columns A & B and I want to write to a blank column which is Col_C. Col_A contains Names and Col_B contains a String. I would like to concatenate all of the values contained in Col_B where the Names (From Col_A) are the same and place the output in a single cell on the first row of Col_C at each name change in Col_A.
I'm have trouble marrying the follwing two Subs in order to accomplish this task:
Sub 1
Sub ConcatNames()
Dim c As Range
For Each c In Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
Cells(1, 3) = Cells(1, 3) & " " & c
Next c
Cells(1, 3) = Trim(Cells(1, 3))
End Sub
Sub 2
Sub UniqueNames()
Dim i As Integer
Dim End_of_Row_A As Integer
Dim Temp As Variant
i = 2
End_of_Row_A = Range("A" & Rows.Count).End(xlUp).Row ' this finds the last used row in a column
For i = i To End_of_Row_A
Temp = Cells(i, 1).Value
If Cells(i - 1, 1).Value <> Temp Then
Cells(i, 3) = Temp
End If
Next i
End Sub
I thought of using Arrays, but have not given that a shot. Any help would be great!
I'm have trouble marrying the follwing two Subs in order to accomplish this task:
Sub 1
Sub ConcatNames()
Dim c As Range
For Each c In Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
Cells(1, 3) = Cells(1, 3) & " " & c
Next c
Cells(1, 3) = Trim(Cells(1, 3))
End Sub
Sub 2
Sub UniqueNames()
Dim i As Integer
Dim End_of_Row_A As Integer
Dim Temp As Variant
i = 2
End_of_Row_A = Range("A" & Rows.Count).End(xlUp).Row ' this finds the last used row in a column
For i = i To End_of_Row_A
Temp = Cells(i, 1).Value
If Cells(i - 1, 1).Value <> Temp Then
Cells(i, 3) = Temp
End If
Next i
End Sub
I thought of using Arrays, but have not given that a shot. Any help would be great!