ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I merge the contents (separated by a comma) of 300+ cells? (https://www.excelbanter.com/excel-discussion-misc-queries/25510-how-do-i-merge-contents-separated-comma-300-cells.html)

elliott

How do I merge the contents (separated by a comma) of 300+ cells?
 


Bill Martin -- (Remove NOSPAM from address)

elliott wrote:

Why do people post notes with no content? Does it take an extra 100mS
to actually type your question with some example of the data rather than
trying to put it all in the subject line which frequently gets truncated
anyhow?

Bill

Gord Dibben

Bill

Because they are using the not-so-efficient CDO and that seems to be the norm
around there.

Gord

On Tue, 10 May 2005 13:43:11 -0400, "Bill Martin -- (Remove NOSPAM from
address)" wrote:

elliott wrote:

Why do people post notes with no content? Does it take an extra 100mS
to actually type your question with some example of the data rather than
trying to put it all in the subject line which frequently gets truncated
anyhow?

Bill



Gord Dibben

Elliot

Are the cells contiguous or random?

If contiguous, easily done with a user defined function.

Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.text) 0 Then sbuf = sbuf & Cell.text & ","
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

=ConCatRange(A1:J30) entered in K1

Or a macro....

Sub ConCat_Cells()
Dim x As Range
Dim y As Range
Dim z As Range
Dim w As String
Dim sbuf As String
On Error GoTo endit
w = InputBox("Enter the Type of De-limiter Desired")
Set z = Application.InputBox("Select Destination Cell", _
"Destination Cell", , , , , , 8)
Application.SendKeys "+{F8}"
Set x = Application.InputBox _
("Select Cells...Contiguous or Non-Contiguous", _
"Cells Selection", , , , , , 8)
For Each y In x
If Len(y.text) 0 Then sbuf = sbuf & y.text & w
Next
z = Left(sbuf, Len(sbuf) - 1)
Exit Sub
endit:
MsgBox "Nothing Selected. Please try again."
End Sub


Gord Dibben Excel MVP

On Tue, 10 May 2005 10:16:03 -0700, "elliott"
wrote:




All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com