PDA

View Full Version : Merged Columns



joshatse
05-03-2007, 08:43 PM
Hi,

I have a spreadsheet and would like to merge the columns.

1 A B C D

2 xxx yyy xxxx

3 Data1 Data2

4 1 2

5 2 3

The macro should look for the String Data2 and merge all the columns from A4-B4 to end of the spreadsheet and store it in C4 onwards. The Result should as shown in BOLD.

1 A B C D

2 xxx yyy xxxx

3 Data1 Data2 MergedData

4 1 2 12

5 2 3 23

Thanks in Advance :)

geekgirlau
05-03-2007, 10:10 PM
I'm not really clear what you want here - can you attach a small sample workbook with a before and after example?

joshatse
05-03-2007, 11:08 PM
Enclosed find the old and new spreadsheet. I would like to Search for the Column with text "Column B" and merge the value of Column A and B starting from Row 10 in to the Column C.

joshatse
05-03-2007, 11:09 PM
Also insert the Column name as "New Column" in column C9.

joshatse
05-06-2007, 01:12 AM
Please Help !!

mdmackillop
05-06-2007, 11:53 AM
Sub DoMerge()
Dim c As Range, cel As Range
Set c = Columns(2).Find("ColumnB")
c.Offset(, 1) = "New Column"
For Each cel In Range(c.Offset(1), Cells(Rows.Count, 2).End(xlUp))
cel.Offset(, 1) = cel.Offset(, -1) & cel
Next
End Sub