none
Using VBA to concatenate columns RRS feed

  • Question

  • Hi, I am trying to take two cells and concatenate them for an unspecified range (it could be 50 cells or it could be 500) using a VBA macro.  I would like to get FrontDimension & Cup combined in the F_demension as well as BackDimension & Cup into B_Dimension.  My sample data is below.  Thanks for all your help in advance!

    FrontSize FrontDimension BackSize BackDimension Cup F_Dimension B_Dimension
    22 13 22 13   A
    32 18 28   18   B
    35 16 28 14   A
    Wednesday, June 3, 2015 12:34 PM

Answers

  • Hello,

    Hope this helps:
    Dim rg As Range
    Dim ws As Worksheet

    Set ws = ActiveSheet
        For Each rg In ws.UsedRange.Rows
            rg.Cells(1, 6) = rg.Cells(1, 2) & rg.Cells(1, 5)
            rg.Cells(1, 7) = rg.Cells(1, 4) & rg.Cells(1, 5)
        Next

    Wouter

    • Proposed as answer by ryguy72 Wednesday, June 3, 2015 7:50 PM
    • Marked as answer by A_Shannon828 Monday, June 8, 2015 6:33 PM
    Wednesday, June 3, 2015 3:45 PM