+ Reply to Thread
Results 1 to 2 of 2

Copy Excel data content listed in 3 columns into a single column

  1. #1
    mooorrona
    Guest

    Copy Excel data content listed in 3 columns into a single column

    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.

  2. #2
    Edwin Tam
    Guest

    Re: 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
    [email protected]
    http://www.vonixx.com



    On 1/12/05 11:33 AM, in article
    [email protected], "mooorrona"
    <[email protected]> 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.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1