View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Sheeloo Sheeloo is offline
external usenet poster
 
Posts: 793
Default Combine information from rows

Are you familiar with VBA programming?

Here is the basic code;
Sub AppendValues()

Dim i, j, FirstRow As Integer
Dim Primarykey, NextId, AppendedString As String
i = 1

Primarykey = ActiveSheet.Cells(i, 1).Value
AppendedString = ActiveSheet.Cells(i, 2).Value

FirstRow = 1

For i = 2 To 21
NextId = ActiveSheet.Cells(i, 1).Value
If NextId = Primarykey Then
AppendedString = AppendedString & ActiveSheet.Cells(i, 2).Value
Else
ActiveSheet.Cells(FirstRow, 2).Value = AppendedString
FirstRow = i
Primarykey = NextId
AppendedString = ActiveSheet.Cells(i, 2).Value
End If
Next

End Sub

Assumption: Data is sorted on Column A which also contain the value for
which one needs to find duplicate rows and joing the values in Column B

This looks for the same value in Col A and appends values in Column B
against the first occurrence in Col A.

Do you want me to complete the code or can you do that yourself?

Can someone out there complete this code for Hannah?

"Sheeloo" wrote:

Understood.
When I get time today, I will try to come up with a solution where I will
combine data from col M from all rows for the same person into col M and
delete other records, and so on for other columns.



"Hannah" wrote:

The basic layout is as detailed below

Contact Company Address No Ordered Cost Contacts Demo
Joe Bloggs ABC1 1 New town 1
Joe Bloggs ABC1 1 New town 567.00
Joe Bloggs ABC1 1 New town 1
Joe Bloggs ABC1 1 New town 1
Jane Doe DEF1 25 New Town 2
Jane Doe DEF1 25 New Town 1,134.00
Jane Doe DEF1 25 New Town 1
Jane Doe DEF1 25 New Town 0

Happy to lose all the duplicates in the first columns, but need to
consolodate the data in the others so that it looks something like:

Contact Company Address No Ordered Cost Contacts Demo
Joe Bloggs ABC1 1 New town 1 567.00 1 1
Jane Doe DEF1 25 New Town 2 1,134.00 1 0

I hope this makes sense

Thank You

"Sheeloo" wrote:

How will you combine the information in columns N-CM if there are multiple
rows for same values in A-M?


"Hannah" wrote:

Good afternoon.

I have an Excel 2003 spreadsheet which has several thousand rows of customer
details. In many of these rows the first columns (A-M - which contain name,
phone number address etc) are duplicated however the data contained in the
following columns (N-CM) is different. Is there any way that I can combine
the rows so that I have one for each individual customer?

I found an example elsewhere on the forum that uses the Index array formula,
but I am not sure how to adapt it so it would work with my spreadsheet.

Many thanks

Hannah