Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 18
Default Automatically merge mulitiple cells to one cells

Any one can help me out here? Preferably without VB.

I have a bunch of continues cells in one column, and want to merge them into
one cell and insert ";" in the between. The number of cells will be dynamic.
Like
A1 8R1234
A2 8R1235
A3 8R1236
A4 8R1237
A5 8R1238
....
Result cell = 8R1234;8R1235;8R1236;8R1237;8R1238;...

As the result will be used in another function, I do not want to use one
spare column beside the data to build up that text string one by one.

Any advice?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Automatically merge mulitiple cells to one cells

You will have to use a UDF or an Add-In to acheive this. Try this UDF (User
Defined function). From workbook launch VBE using Alt+F11. From menu Insert a
Module and paste the below function.Close and get back to workbook and try
the below formula.

=CONCATRANGE(A1:A5,";")

Function CONCATRANGE(varRange As Range, Optional varDelimiter As String)
Dim varTemp As Range
For Each varTemp In varRange
CONCATRANGE = CONCATRANGE & varDelimiter & varTemp
Next
If varDelimiter < vbNullString Then CONCATRANGE = Mid(CONCATRANGE, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Edward Wang" wrote:

Any one can help me out here? Preferably without VB.

I have a bunch of continues cells in one column, and want to merge them into
one cell and insert ";" in the between. The number of cells will be dynamic.
Like
A1 8R1234
A2 8R1235
A3 8R1236
A4 8R1237
A5 8R1238
...
Result cell = 8R1234;8R1235;8R1236;8R1237;8R1238;...

As the result will be used in another function, I do not want to use one
spare column beside the data to build up that text string one by one.

Any advice?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 18
Default Automatically merge mulitiple cells to one cells

Thank you, Jacob! It works!

A further question, if I have another column beside to column A, like below.
I want to merge the Text of Column A based on the condition of Column B.
Say if I only Pick A from Column B, the result will be "8R1234;8R1236;8R1238"
Column A Column B
8R1234 A
8R1235 B
8R1236 A
8R1237 B
8R1238 A

Thanks in advance!

"Jacob Skaria" wrote:

You will have to use a UDF or an Add-In to acheive this. Try this UDF (User
Defined function). From workbook launch VBE using Alt+F11. From menu Insert a
Module and paste the below function.Close and get back to workbook and try
the below formula.

=CONCATRANGE(A1:A5,";")

Function CONCATRANGE(varRange As Range, Optional varDelimiter As String)
Dim varTemp As Range
For Each varTemp In varRange
CONCATRANGE = CONCATRANGE & varDelimiter & varTemp
Next
If varDelimiter < vbNullString Then CONCATRANGE = Mid(CONCATRANGE, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Edward Wang" wrote:

Any one can help me out here? Preferably without VB.

I have a bunch of continues cells in one column, and want to merge them into
one cell and insert ";" in the between. The number of cells will be dynamic.
Like
A1 8R1234
A2 8R1235
A3 8R1236
A4 8R1237
A5 8R1238
...
Result cell = 8R1234;8R1235;8R1236;8R1237;8R1238;...

As the result will be used in another function, I do not want to use one
spare column beside the data to build up that text string one by one.

Any advice?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Automatically merge mulitiple cells to one cells

Try the below...(Taken from an earlier post of mine)

=CONCATBY($A$1:$B$5,A1,2)

$A$1:$B$5 - Array
A1 - lookup
2 - Column to be combined..


Try this UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

Function CONCATBY(varRange As Range, _
strData As String, intCol As Integer)
Dim lngRow As Long
For lngRow = 1 To varRange.Rows.Count
If varRange(lngRow, 1) = strData Then
CONCATBY = CONCATBY & "," & varRange(lngRow, intCol)
End If
Next
CONCATBY = Mid(CONCATBY, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Edward Wang" wrote:

Thank you, Jacob! It works!

A further question, if I have another column beside to column A, like below.
I want to merge the Text of Column A based on the condition of Column B.
Say if I only Pick A from Column B, the result will be "8R1234;8R1236;8R1238"
Column A Column B
8R1234 A
8R1235 B
8R1236 A
8R1237 B
8R1238 A

Thanks in advance!

"Jacob Skaria" wrote:

You will have to use a UDF or an Add-In to acheive this. Try this UDF (User
Defined function). From workbook launch VBE using Alt+F11. From menu Insert a
Module and paste the below function.Close and get back to workbook and try
the below formula.

=CONCATRANGE(A1:A5,";")

Function CONCATRANGE(varRange As Range, Optional varDelimiter As String)
Dim varTemp As Range
For Each varTemp In varRange
CONCATRANGE = CONCATRANGE & varDelimiter & varTemp
Next
If varDelimiter < vbNullString Then CONCATRANGE = Mid(CONCATRANGE, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Edward Wang" wrote:

Any one can help me out here? Preferably without VB.

I have a bunch of continues cells in one column, and want to merge them into
one cell and insert ";" in the between. The number of cells will be dynamic.
Like
A1 8R1234
A2 8R1235
A3 8R1236
A4 8R1237
A5 8R1238
...
Result cell = 8R1234;8R1235;8R1236;8R1237;8R1238;...

As the result will be used in another function, I do not want to use one
spare column beside the data to build up that text string one by one.

Any advice?

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 18
Default Automatically merge mulitiple cells to one cells

it works! Thanks!

I just made two minimum changes:
1. using ";" in the between
2. using "instr" function to replace "=" logical judgement

"Jacob Skaria" wrote:

Try the below...(Taken from an earlier post of mine)

=CONCATBY($A$1:$B$5,A1,2)

$A$1:$B$5 - Array
A1 - lookup
2 - Column to be combined..


Try this UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

Function CONCATBY(varRange As Range, _
strData As String, intCol As Integer)
Dim lngRow As Long
For lngRow = 1 To varRange.Rows.Count
If varRange(lngRow, 1) = strData Then
CONCATBY = CONCATBY & "," & varRange(lngRow, intCol)
End If
Next
CONCATBY = Mid(CONCATBY, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Edward Wang" wrote:

Thank you, Jacob! It works!

A further question, if I have another column beside to column A, like below.
I want to merge the Text of Column A based on the condition of Column B.
Say if I only Pick A from Column B, the result will be "8R1234;8R1236;8R1238"
Column A Column B
8R1234 A
8R1235 B
8R1236 A
8R1237 B
8R1238 A

Thanks in advance!

"Jacob Skaria" wrote:

You will have to use a UDF or an Add-In to acheive this. Try this UDF (User
Defined function). From workbook launch VBE using Alt+F11. From menu Insert a
Module and paste the below function.Close and get back to workbook and try
the below formula.

=CONCATRANGE(A1:A5,";")

Function CONCATRANGE(varRange As Range, Optional varDelimiter As String)
Dim varTemp As Range
For Each varTemp In varRange
CONCATRANGE = CONCATRANGE & varDelimiter & varTemp
Next
If varDelimiter < vbNullString Then CONCATRANGE = Mid(CONCATRANGE, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Edward Wang" wrote:

Any one can help me out here? Preferably without VB.

I have a bunch of continues cells in one column, and want to merge them into
one cell and insert ";" in the between. The number of cells will be dynamic.
Like
A1 8R1234
A2 8R1235
A3 8R1236
A4 8R1237
A5 8R1238
...
Result cell = 8R1234;8R1235;8R1236;8R1237;8R1238;...

As the result will be used in another function, I do not want to use one
spare column beside the data to build up that text string one by one.

Any advice?



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default Automatically merge mulitiple cells to one cells


Hi,

Download and install the following addin
http://www.download.com/Morefunc/300...-10423159.html and then use the
MCONCAT() function

=MCONCAT(A1:A5,";")

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Edward Wang" wrote in message
...
Any one can help me out here? Preferably without VB.

I have a bunch of continues cells in one column, and want to merge them
into
one cell and insert ";" in the between. The number of cells will be
dynamic.
Like
A1 8R1234
A2 8R1235
A3 8R1236
A4 8R1237
A5 8R1238
...
Result cell = 8R1234;8R1235;8R1236;8R1237;8R1238;...

As the result will be used in another function, I do not want to use one
spare column beside the data to build up that text string one by one.

Any advice?


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
Merge cells north shore writer Excel Discussion (Misc queries) 1 March 26th 09 09:43 PM
how do I merge cells into one then delete the original cells? LLR Excel Worksheet Functions 2 March 7th 08 10:59 PM
mulitiple cells in a drop down Kaar Excel Discussion (Misc queries) 1 November 24th 06 02:27 PM
Merge Cells Aaron Excel Discussion (Misc queries) 1 November 15th 06 09:38 PM
How do I merge cells in Excel, like just 2 cells to make one big . chattacat Excel Discussion (Misc queries) 2 January 19th 05 04:25 PM


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