+ Reply to Thread
Results 1 to 3 of 3

look up and append result to row for multiple identical entries

  1. #1
    Registered User
    Join Date
    05-03-2004
    Posts
    39

    look up and append result to row for multiple identical entries

    Hi!
    I hope my subject line was somewhat descriptive.

    I have the following problem:
    1. Column A of my extremely huge spreadsheet contains id numbers.
    2. ID numbers appear more than once, because the same case is spread across multiple rows (i didn't set this thing up...)
    3. I need each unique case to be in one single row.

    Basically, I need to convert ...

    A B C D
    id1 1 2 1
    id1 3 4 5
    id2 2 1 5
    id2 9 2 3

    ...to

    A B C D E F G
    id1 1 2 1 3 4 5
    id2 2 1 5 9 2 3

    Added difficulty:
    The number of rows over which one unique case spreads is not constant. E.g., I have 10 id1, 20 id2, 15 id3...


    Can anyone help? I'd be forever grateful!

    as

  2. #2
    PY & Associates
    Guest

    RE: look up and append result to row for multiple identical entries

    How about this?

    Sub Macro1()
    Range("A1").CurrentRegion.Select
    Selection.Sort Key1:=Range("A1")
    lrow = Selection.Rows.Count

    For i = lrow To 2 Step -1
    If Range("A" & i) <> Range("A" & i - 1) Then GoTo donothing
    lcol = Range("A" & i, Range("A" & i).End(xlToRight)).Columns.Count
    Range(Cells(i, 2), Cells(i, lcol)).Copy
    lcol = Range("A" & i - 1, Range("A" & i - 1).End(xlToRight)).Columns.Count
    Cells(i - 1, lcol + 1).Select
    ActiveSheet.Paste
    Range("A" & i).EntireRow.Delete
    donothing:
    Next i

    End Sub


    "as_sass" wrote:

    >
    > Hi!
    > I hope my subject line was somewhat descriptive.
    >
    > I have the following problem:
    > 1. Column A of my extremely huge spreadsheet contains id numbers.
    > 2. ID numbers appear more than once, because the same case is spread
    > across multiple rows (i didn't set this thing up...)
    > 3. I need each unique case to be in one single row.
    >
    > Basically, I need to convert ...
    >
    > A B C D
    > id1 1 2 1
    > id1 3 4 5
    > id2 2 1 5
    > id2 9 2 3
    >
    > ...to
    >
    > A B C D E F G
    > id1 1 2 1 3 4 5
    > id2 2 1 5 9 2 3
    >
    > Added difficulty:
    > The number of rows over which one unique case spreads is not constant.
    > E.g., I have 10 id1, 20 id2, 15 id3...
    >
    >
    > Can anyone help? I'd be forever grateful!
    >
    > as
    >
    >
    > --
    > as_sass
    > ------------------------------------------------------------------------
    > as_sass's Profile: http://www.excelforum.com/member.php...fo&userid=9065
    > View this thread: http://www.excelforum.com/showthread...hreadid=399950
    >
    >


  3. #3
    Registered User
    Join Date
    05-03-2004
    Posts
    39

    Thank you!

    Works like a charm!
    Can I send you flowers?!?

    as

    PS: actually, just ran into a problem:
    I have several ID numbers that appear more than 250 times.
    That means I'll run into the problem that the worksheet is not "long" enough.

    Apart from "use a database and not Excel", does anybody know a solution to this problem? Like writing the whole thing as one row to a text file, for example?

    Thanks!

    as
    Last edited by as_sass; 08-31-2005 at 04:50 PM.

+ 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