Try something like the following, where
C_COLUMNS_TO_MERGE
is the number of columns to merge
C_START_COLUMN
is the first column of data to merge
C_START_ROW
is the row to start on.
The procedure will start with row C_START_ROW and continue downwards until
an empty cell is encountered in C_START_COLUMN.
Sub MergeThem()
Const C_COLUMNS_TO_MERGE = 3
Const C_START_COLUMN = 1
Const C_START_ROW = 2
Dim S As String
Dim Ndx As Long
Dim Rng As Range
Set Rng = ActiveSheet.Cells(C_START_ROW, C_START_COLUMN)
Application.DisplayAlerts = False
Do Until Rng.Value = vbNullString
S = vbNullString
For Ndx = 1 To C_COLUMNS_TO_MERGE
S = S & Rng(1, Ndx).Text & IIf(Ndx < C_COLUMNS_TO_MERGE, " ", "")
Next Ndx
Rng.Resize(1, C_COLUMNS_TO_MERGE).Merge
Rng.Value = S
Set Rng = Rng(2, 1)
Loop
Application.DisplayAlerts = True
End Sub
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"vlad" wrote in message
...
I have 10+ columns of data. I need to have all columns merged one under
another into one column.For example column A. I can do it manually by
cutting
the data in each column and pasting it below the last record in column A.
But
there should be a way to automate that.Any help with the code will be
apprciated