+ Reply to Thread
Results 1 to 3 of 3

Merge Row Data

  1. #1
    Registered User
    Join Date
    08-23-2004
    Posts
    9

    Merge Row Data

    Does anyone have a simple way of merging row data into one cell with a comma or line separator?
    4565 4565|5123|212|213 etc
    5123
    212
    213
    2112
    2121
    21212
    221

    Any clever ideas are welcome that would function on the fly for lots of rows of data.

    Thank you

  2. #2
    Gord Dibben
    Guest

    Re: Merge Row Data

    Walan

    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

    Alternative.............UDF

    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:A15)


    Gord Dibben Excel MVP


    On Mon, 26 Dec 2005 16:07:44 -0600, walan
    <[email protected]> wrote:

    >
    >Does anyone have a simple way of merging row data into one cell with a
    >comma or line separator?
    >4565 4565|5123|212|213 etc
    >5123
    >212
    >213
    >2112
    >2121
    >21212
    >221
    >
    >Any clever ideas are welcome that would function on the fly for lots of
    >rows of data.
    >
    >Thank you


  3. #3
    Registered User
    Join Date
    08-23-2004
    Posts
    9

    Merging Rows

    Dibben,
    This does the trick, you are the best MVP. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1