look up and append result to row for multiple identical entries

A

as_sass

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 sprea
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!

a
 
P

PY & Associates

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
 
A

as_sass

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 solutio
to this problem? Like writing the whole thing as one row to a text file
for example?

Thanks!

a
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top