Consulting

Results 1 to 6 of 6

Thread: Merged Columns

  1. #1
    VBAX Regular
    Joined
    Apr 2007
    Posts
    13
    Location

    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

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    I'm not really clear what you want here - can you attach a small sample workbook with a before and after example?

  3. #3
    VBAX Regular
    Joined
    Apr 2007
    Posts
    13
    Location
    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.

  4. #4
    VBAX Regular
    Joined
    Apr 2007
    Posts
    13
    Location
    Also insert the Column name as "New Column" in column C9.

  5. #5
    VBAX Regular
    Joined
    Apr 2007
    Posts
    13
    Location
    Please Help !!

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [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
  •