Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Need help with combining cells to one

I have got a issue and need some help. I have a sheet as follows:

Sector BR CC TCH_List
1 1 1113
1 2 329
1 3 1153
1 4 1155
1 5 1157
2 1 823
2 2 115
2 3 9
3 1 1145
3 2 817
3 3 789
3 4 1013
3 5 797

Finally, I want have a sheet like this:

Sector BR CC TCH_List
1 1 1113 1113;329;1153;1155;1157
2 1 823 823;115;9;1145
3 1 1145 1145;817;789;1013;797

I need all the CC column with the same sector value go to the TCH_list and
separate with ";". and just BR=1 rows are kept.

my question is: is there any macro or formula could be used for such a
request?

thank u.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Need help with combining cells to one

Try This for combining second column values into the first row (in Col C) for
each distinct value in Col A

Sub CombineRows()
Dim Colb As String
Colb = ""
i = Range("A50").End(xlUp).Row
Do
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
Colb = Cells(i, 2).Value & ";" & Colb

'Rows(i).Delete
Else
Colb = Cells(i, 2).Value & ";" & Colb
Cells(i, 4).Value = Colb
Colb = ""
End If
i = i - 1
Loop Until i < 2
Colb = Cells(i, 2).Value & ";" & Colb
Cells(i, 4).Value = Colb
Colb = ""

End Sub

Remove the comment if you want to delete the other rows. Increase 50 to
number of rows you have in i = Range("A50").End(xlUp).Row

You can adapt this to combine column C too...

Let me know if you need help with that...

"Coolquicc" wrote:

I have got a issue and need some help. I have a sheet as follows:

Sector BR CC TCH_List
1 1 1113
1 2 329
1 3 1153
1 4 1155
1 5 1157
2 1 823
2 2 115
2 3 9
3 1 1145
3 2 817
3 3 789
3 4 1013
3 5 797

Finally, I want have a sheet like this:

Sector BR CC TCH_List
1 1 1113 1113;329;1153;1155;1157
2 1 823 823;115;9;1145
3 1 1145 1145;817;789;1013;797

I need all the CC column with the same sector value go to the TCH_list and
separate with ";". and just BR=1 rows are kept.

my question is: is there any macro or formula could be used for such a
request?

thank u.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Need help with combining cells to one

Thank you very much Sheeloo, which helped me a lot.

Just one thing I want to mention, a definition of "i" should be added before
we use it.

"Sheeloo" wrote:

Try This for combining second column values into the first row (in Col C) for
each distinct value in Col A

Sub CombineRows()
Dim Colb As String
Colb = ""
i = Range("A50").End(xlUp).Row
Do
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
Colb = Cells(i, 2).Value & ";" & Colb

'Rows(i).Delete
Else
Colb = Cells(i, 2).Value & ";" & Colb
Cells(i, 4).Value = Colb
Colb = ""
End If
i = i - 1
Loop Until i < 2
Colb = Cells(i, 2).Value & ";" & Colb
Cells(i, 4).Value = Colb
Colb = ""

End Sub

Remove the comment if you want to delete the other rows. Increase 50 to
number of rows you have in i = Range("A50").End(xlUp).Row

You can adapt this to combine column C too...

Let me know if you need help with that...

"Coolquicc" wrote:

I have got a issue and need some help. I have a sheet as follows:

Sector BR CC TCH_List
1 1 1113
1 2 329
1 3 1153
1 4 1155
1 5 1157
2 1 823
2 2 115
2 3 9
3 1 1145
3 2 817
3 3 789
3 4 1013
3 5 797

Finally, I want have a sheet like this:

Sector BR CC TCH_List
1 1 1113 1113;329;1153;1155;1157
2 1 823 823;115;9;1145
3 1 1145 1145;817;789;1013;797

I need all the CC column with the same sector value go to the TCH_list and
separate with ";". and just BR=1 rows are kept.

my question is: is there any macro or formula could be used for such a
request?

thank u.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Need help with combining cells to one

Glad I could help...

Declaration is necessary if you have OPTION EXPLICIT set... Good habit though

"Coolquicc" wrote:

Thank you very much Sheeloo, which helped me a lot.

Just one thing I want to mention, a definition of "i" should be added before
we use it.

"Sheeloo" wrote:

Try This for combining second column values into the first row (in Col C) for
each distinct value in Col A

Sub CombineRows()
Dim Colb As String
Colb = ""
i = Range("A50").End(xlUp).Row
Do
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
Colb = Cells(i, 2).Value & ";" & Colb

'Rows(i).Delete
Else
Colb = Cells(i, 2).Value & ";" & Colb
Cells(i, 4).Value = Colb
Colb = ""
End If
i = i - 1
Loop Until i < 2
Colb = Cells(i, 2).Value & ";" & Colb
Cells(i, 4).Value = Colb
Colb = ""

End Sub

Remove the comment if you want to delete the other rows. Increase 50 to
number of rows you have in i = Range("A50").End(xlUp).Row

You can adapt this to combine column C too...

Let me know if you need help with that...

"Coolquicc" wrote:

I have got a issue and need some help. I have a sheet as follows:

Sector BR CC TCH_List
1 1 1113
1 2 329
1 3 1153
1 4 1155
1 5 1157
2 1 823
2 2 115
2 3 9
3 1 1145
3 2 817
3 3 789
3 4 1013
3 5 797

Finally, I want have a sheet like this:

Sector BR CC TCH_List
1 1 1113 1113;329;1153;1155;1157
2 1 823 823;115;9;1145
3 1 1145 1145;817;789;1013;797

I need all the CC column with the same sector value go to the TCH_list and
separate with ";". and just BR=1 rows are kept.

my question is: is there any macro or formula could be used for such a
request?

thank u.

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
combining two cells Michelle Excel Discussion (Misc queries) 3 September 20th 07 05:20 PM
Combining cells BAKERSMAN Excel Discussion (Misc queries) 2 June 26th 07 07:33 PM
Combining 2 cells Steved Excel Worksheet Functions 2 July 26th 06 08:02 AM
combining cells Mindy Excel Worksheet Functions 1 January 9th 06 09:16 PM
combining cells lyneday Excel Discussion (Misc queries) 2 December 3rd 04 05:45 PM


All times are GMT +1. The time now is 02:23 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"