#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default concatenate

I have the following

Col A Col Q Col Z
746 123
746 4789
746 124
748 8566
748 9586
748 852

I have this for about 3100 lines of data. I need to if Col A is the same
the return col B concatenate. So for Trailer # 746 return 123, 4789, 124 in
col Z. I did this about 2 years ago and quite frankly I had some help and no
longer remember how the macro needs to be written.

Please help. Thanks, Wanda
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default concatenate


iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
tmp = Cells(1, "A").Value
sNums = Cells(1, "Q").Value
For i = 2 To iLastRow
If Cells(i, "A").Value = tmp Then
sNums = sNums & ", " & Cells(i, "Q").Value
Else
j = j + 1
Cells(j, "Z").Value = sNums
sNums = Cells(i, "Q").Value
tmp = Cells(i, "A").Value
End If
Next i
j = j + 1
Cells(j, "Z").Value = sNums


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"gwtreece" wrote in message
...
I have the following

Col A Col Q Col Z
746 123
746 4789
746 124
748 8566
748 9586
748 852

I have this for about 3100 lines of data. I need to if Col A is the same
the return col B concatenate. So for Trailer # 746 return 123, 4789, 124

in
col Z. I did this about 2 years ago and quite frankly I had some help and

no
longer remember how the macro needs to be written.

Please help. Thanks, Wanda



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default concatenate

Bob, I just came across your code for concatenating. It works great. I've
needed this for about a hundred years--gives me the flexibility I couldn't
get any other way. Thanks!

"Bob Phillips" wrote:


iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
tmp = Cells(1, "A").Value
sNums = Cells(1, "Q").Value
For i = 2 To iLastRow
If Cells(i, "A").Value = tmp Then
sNums = sNums & ", " & Cells(i, "Q").Value
Else
j = j + 1
Cells(j, "Z").Value = sNums
sNums = Cells(i, "Q").Value
tmp = Cells(i, "A").Value
End If
Next i
j = j + 1
Cells(j, "Z").Value = sNums


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"gwtreece" wrote in message
...
I have the following

Col A Col Q Col Z
746 123
746 4789
746 124
748 8566
748 9586
748 852

I have this for about 3100 lines of data. I need to if Col A is the same
the return col B concatenate. So for Trailer # 746 return 123, 4789, 124

in
col Z. I did this about 2 years ago and quite frankly I had some help and

no
longer remember how the macro needs to be written.

Please help. Thanks, Wanda




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
CONCATENATE coddave Excel Discussion (Misc queries) 3 August 2nd 05 07:02 AM
I know how to concatenate ,can one de-concatenate to split date? QUICK BOOKS PROBLEM- New Users to Excel 1 July 26th 05 05:07 PM
concatenate jeanette.rimmer Excel Worksheet Functions 3 July 25th 05 11:41 AM
Un - Concatenate? JudithJubilee Excel Worksheet Functions 2 July 11th 05 09:57 AM
Un - Concatenate ? Rednelle Excel Worksheet Functions 9 May 26th 05 09:41 PM


All times are GMT +1. The time now is 10:07 PM.

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"