-
Merged Columns
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
-
I'm not really clear what you want here - can you attach a small sample workbook with a before and after example?
-
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.
-
Also insert the Column name as "New Column" in column C9.
-
-
[VBA]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[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules