![]() |
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. |
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" wrote in message ... 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. |
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. |
All times are GMT +1. The time now is 04:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com