Concatenate a Range of Strings in Excel

Most of us have used the Concatenate() function in Excel. It is a neat function that saves you the trouble of keying in “&” between the range addresses. The only thing that would make this awesome would be the ability to concatenate an entire range. That would be way more useful than having to comma separate each cell that you want to concatenate.

Consequently, I wrote this function that will concatenate all the cells in a specified range. It also has the option to include a “separator” text and it ignores blank cells.

'Function to Concatenate the values stored in every Cell of a Range
'Author     : Ejaz Ahmed
'Date       : 14 November 2013
'Website    :
Function ConcRange(ByRef WhichRange As Range, _
            Optional ByVal Seperator As String = vbNullString) As Variant

'Begin by setting the ConcRange to a blank string
ConcRange = vbNullString

'Declare a Range object to use in the For Each Loop
Dim rngCell As Range

'For Each loop concatenates all the cells in the range
For Each rngCell In WhichRange
    If ConcRange = vbNullString Then
        If Not rngCell.Value = vbNullString Then
            ConcRange = CStr(rngCell.Value2)
        End If
        If Not rngCell.Value = vbNullString Then
            ConcRange = ConcRange & Seperator & CStr(rngCell.Value2)
        End If
    End If
Next rngCell

End Function

Below is screenshot of a spreadsheet illustrating the use of this Functions:

Concatenate Range

Example : Concatenate Range

Categories: User Defined FunctionTags: , , ,

If you liked it, let me know. If you didn't make sure you let me know!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: