Wednesday, June 15, 2011

How to Concatenate string in VBA

How to Concatenate string in VBA

In excel if you have two columns “A” and “B” and you want to concatenate these two columns into single columns suppose “C” then you can use this code for concatenation of two columns. Make its macro and use this code
Sub ConcatenateString()

        Sheets("Sheet1").Select
        Range("C1").Select

        Do Until Selection.Offset(0, -2).Value = ""
                Selection.Value = Selection.Offset(0, -2).Value & " " & Selection.Offset(0, -1)
                Selection.Offset(1, 0).Select
        Loop

        Range("A1").Select

End Sub

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.