View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Edwin Tam[_4_] Edwin Tam[_4_] is offline
external usenet poster
 
Posts: 23
Default Copy Excel data content listed in 3 columns into a singlecolumn

Try the macro below.

To use the macro:
1) Have the data sorted by the "Name" column.
2) Select any cell in your data
3) Run the macro

'-------------------------
Sub combine_rows()
Dim tmp As Single, tmp2$

tmp2 = Selection.Range("A1").CurrentRegion.Address(False, False)

With ActiveSheet.Range(tmp2).Columns(1)
If .Rows.Count = 2 Then
For tmp = .Rows.Count To 2 Step -1
If .Rows(tmp).Value = .Rows(tmp - 1).Value Then
.Rows(tmp - 1).Offset(0, 1).Value = _
.Rows(tmp - 1).Offset(0, 1).Value & ", " & _
.Rows(tmp).Offset(0, 1).Value
.Rows(tmp - 1).Offset(0, 2).Value = _
.Rows(tmp - 1).Offset(0, 2).Value + _
.Rows(tmp).Offset(0, 2).Value
.Rows(tmp).EntireRow.Delete
End If
Next
End If
End With
End Sub
'-------------------------

Regards,
Edwin Tam

http://www.vonixx.com



On 1/12/05 11:33 AM, in article
, "mooorrona"
wrote:

My speadsheet looks like this:
Name Computer name count
Jones cpu1 5
Jones cpu2 6
Jones cpu4 15

I need for it to appear like this:
Name Computer name count
Jones cpu1,cpu2 and cpu4 26

How can this be accomplished. Thanks.