Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Concatenating problems

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.programming
external usenet poster
 
Posts: 703
Default Concatenating problems

Try this:

Dim i As Long
Dim LastRow As Long
Dim SaveResponse As String

LastRow = 7 '(whatever)

For i = LastRow To 3 Step -1
If Cells(i, 1) = Cells(i - 1, 1) Then
SaveResponse = Cells(i, 2)
Cells(i, 1).EntireRow.Delete
Cells(i - 1, 2) = Cells(i - 1, 2) & " " & SaveResponse
End If
Next i

Column B should be formatted as Text

"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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Concatenating problems

Thanks, but I don't think that's what I was shooting for. Either that or I'm
not properly utilizing the code (which is entirely possible).

"Charlie" wrote:

Try this:

Dim i As Long
Dim LastRow As Long
Dim SaveResponse As String

LastRow = 7 '(whatever)

For i = LastRow To 3 Step -1
If Cells(i, 1) = Cells(i - 1, 1) Then
SaveResponse = Cells(i, 2)
Cells(i, 1).EntireRow.Delete
Cells(i - 1, 2) = Cells(i - 1, 2) & " " & SaveResponse
End If
Next i

Column B should be formatted as Text

"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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Concatenating problems

Sorry, I missed the "into one column" part. I presume your data ranges from
"A2:B2" to "A<LastRow:B<LastRow". Also, I don't know if you want the
vertical bar "|" literally inserted into the result.

Dim i As Long
Dim LastRow As Long

LastRow = 7

For i = LastRow To 3 Step -1
If Cells(i, 1) = Cells(i - 1, 1) Then
Cells(i - 1, 2) = Cells(i - 1, 2) & " " & Cells(i, 2)
Cells(i, 1).EntireRow.Delete
LastRow = LastRow - 1
End If
Next i

For i = 2 To LastRow
Cells(i, 1) = Cells(i, 1) & " " & Cells(i, 2)
Cells(i, 2).ClearContents
Next i


"Jack" wrote:

Thanks, but I don't think that's what I was shooting for. Either that or I'm
not properly utilizing the code (which is entirely possible).

"Charlie" wrote:

Try this:

Dim i As Long
Dim LastRow As Long
Dim SaveResponse As String

LastRow = 7 '(whatever)

For i = LastRow To 3 Step -1
If Cells(i, 1) = Cells(i - 1, 1) Then
SaveResponse = Cells(i, 2)
Cells(i, 1).EntireRow.Delete
Cells(i - 1, 2) = Cells(i - 1, 2) & " " & SaveResponse
End If
Next i

Column B should be formatted as Text

"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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenating problems


Hi,

I am interested if either of these solutions assisted you? I have the
same issue. I have tried both scripts but I am getting errors returned.
My VB skills are very rusty though. My columns a

Room No | Guest Name
1 | Mr Smith
5 | Miss Green
5 | Mr Brown
6 | Mr & Mrs Gray

Regards,

Gena


--
genas
------------------------------------------------------------------------
genas's Profile: http://www.excelforum.com/member.php...o&userid=35329
View this thread: http://www.excelforum.com/showthread...hreadid=550419



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
concatenating TED Excel Worksheet Functions 3 February 13th 09 01:03 AM
concatenating Yosh Excel Discussion (Misc queries) 7 February 7th 07 09:03 PM
Concatenating % confused Excel Discussion (Misc queries) 2 September 21st 06 03:49 AM
Concatenating Himu Excel Programming 7 July 23rd 05 08:58 PM
Concatenating Metalteck New Users to Excel 10 May 4th 05 01:01 AM


All times are GMT +1. The time now is 03:26 AM.

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

About Us

"It's about Microsoft Excel"