+ Reply to Thread
Results 1 to 3 of 3

Macro to combine data in a column

Hybrid View

  1. #1
    Janna
    Guest

    Macro to combine data in a column

    If I select a block of contiguous cells in the same column, is it possible to
    create a macro that will combine all the data, in the order of top selected
    cell to the bottom selected cell and place it in proper order into a single
    cell (the top cell of the selected block)--I don't want to merge the cells, I
    just want all the data from a block of selected cells to be placed into one
    cell.

    Thanks.

  2. #2
    Tim Williams
    Guest

    Re: Macro to combine data in a column

    Do you want to clear all of the other cells?

    Sub test()
    Dim c As Range
    Dim s As String

    For Each c In Selection
    s = s & IIf(s = "", "", Chr(10)) & c.Value
    Next c

    Selection.Cells.Value = ""
    Selection.Cells(1).Value = s
    End Sub


    Tim.


    "Janna" <Janna@discussions.microsoft.com> wrote in message
    news:079F1862-E6FB-4125-82DC-35898B7E74F9@microsoft.com...
    > If I select a block of contiguous cells in the same column, is it
    > possible to
    > create a macro that will combine all the data, in the order of top
    > selected
    > cell to the bottom selected cell and place it in proper order into a
    > single
    > cell (the top cell of the selected block)--I don't want to merge the
    > cells, I
    > just want all the data from a block of selected cells to be placed
    > into one
    > cell.
    >
    > Thanks.




  3. #3
    DMoney
    Guest

    RE: Macro to combine data in a column

    This should get u started

    Sub combine()

    C = Empty
    Range("B4:b8").Select
    D = ActiveCell.Value
    Dim A As String
    A = Selection.Address
    Dim C As String
    Do Until ActiveCell = ""
    C = C & D
    D = ActiveCell.Offset(1, 0).Value
    ActiveCell.Offset(1, 0).Activate
    Loop
    Range(A).Select
    ActiveCell = C

    End Sub

    "Janna" wrote:

    > If I select a block of contiguous cells in the same column, is it possible to
    > create a macro that will combine all the data, in the order of top selected
    > cell to the bottom selected cell and place it in proper order into a single
    > cell (the top cell of the selected block)--I don't want to merge the cells, I
    > just want all the data from a block of selected cells to be placed into one
    > cell.
    >
    > Thanks.


+ 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