CONCATENATE Function in Excel with code example

CONCATENATE Function in Excel with code example


CONCATENATE Function is a worksheet function in excel which concatenate or join two or more strings and returns a single string. Concatenate function requires at least one argument and can take upto 255 arguments. In VBA (Visual Basic for Application) the concatenation can be achieved using ampersand (&).


=CONCATENATE(text1, text2, text3, text4, …………text255)

Formula implementation


Using & (Ampersand)


Code example

Public Function JoinStrings(oRange As Range) As String
    JoinStrings = ""
    'Object to iterate each cell
    Dim ocell As Range
    'Iterate each cell
    For Each ocell In oRange.Cells
        'Join string
        JoinStrings = JoinStrings & ocell.Text & " "
    Next ocell
    'Memory cleanup
    Set ocell = Nothing
End Function



Please leave your comments or queries under comment section also please do subscribe to our blogs to keep your self upto date.

Leave a Reply

Your email address will not be published. Required fields are marked *