Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jack
 
Posts: n/a
Default Concatenating Problem

Hello,

I have an Excel sheet with a header row containing the following fields:

Customer ID | Numeric Response

The rows beneath contain data as such:

5 | 1
5 | 4
5 | 7
7 | 2
7 | 3
8 | 1

Basically Customer ID "5" answered 1,4, and 7 and has a separate row for
each answer (same with Customer ID "7" answering 2 and 3, etc...)

I would like to concatenate the Response row into one field so that
ultimately I have one column that looks like:

Customer ID | Numeric Response

5 | 1 4 7
7 | 2 3
8 | 1
etc....

Thank you in advance,
Jack
  #2   Report Post  
Posted to microsoft.public.excel.misc
Miguel Zapico
 
Posts: n/a
Default Concatenating Problem

You may use a macro like this:
Sub ConcatenateID()
Dim rngOrig, rngDest As Range
Dim i, d, a, Values

Set d = CreateObject("Scripting.Dictionary")
'This is the starting range of the current data
Set rngOrig = Worksheets("Sheet3").Range("A1")
'This is the starting range of the destination
Set rngDest = Worksheets("Sheet3").Range("C1")
i = 0

'Gather the information, loop until we find a blank
Do While rngOrig.Offset(i, 0).Value < ""
Values = Split(rngOrig.Offset(i, 0).Value, " | ")
If d.exists(Values(0)) Then
d(Values(0)) = d(Values(0)) & " " & Values(1)
Else
d.Add Values(0), Values(1)
End If
i = i + 1
Loop

'Print the information in the destination range
a = d.keys
For i = 0 To d.Count - 1
rngDest.Offset(i, 0).Value = a(i) & " | " & d(a(i))
Next
End Sub

Hope this helps,
Miguel.

"Jack" wrote:

Hello,

I have an Excel sheet with a header row containing the following fields:

Customer ID | Numeric Response

The rows beneath contain data as such:

5 | 1
5 | 4
5 | 7
7 | 2
7 | 3
8 | 1

Basically Customer ID "5" answered 1,4, and 7 and has a separate row for
each answer (same with Customer ID "7" answering 2 and 3, etc...)

I would like to concatenate the Response row into one field so that
ultimately I have one column that looks like:

Customer ID | Numeric Response

5 | 1 4 7
7 | 2 3
8 | 1
etc....

Thank you in advance,
Jack

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
have some problem with database baldamenti Excel Discussion (Misc queries) 1 October 13th 05 05:38 PM
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM
Problem With Reference Update Egon Excel Worksheet Functions 17 July 16th 05 05:45 AM
Copy an Drag cell Formula Problem Nat Excel Discussion (Misc queries) 1 June 20th 05 03:24 PM
Freeze Pane problem in shared workbooks JM Excel Discussion (Misc queries) 1 February 1st 05 12:04 AM


All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"