Try this change
Public Function ConcatAll(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString) As String
'Created by TigerAvatar at www.excelforum.com, September 2012
'Purpose is to concatenate many strings into a single string
'Can be used with arrays, range objects, and collections
Dim DataIndex As Variant 'Used to loop through arrays, range objects, and collections
Dim strResult As String 'Used to build the result string
'Test if varData is an Array, Range, or Collection
If IsArray(varData) _
Or TypeName(varData) = "Range" _
Or TypeName(varData) = "Collection" Then
'Found to be an, array, range object, or collection
'Loop through each item in varData
For Each DataIndex In varData
'Check if the item isn't empty and if so add it to the result with the delimiter
If Len(DataIndex) > 0 Then strResult = strResult & "-" & WorksheetFunction.Text(DataIndex, "000")
Next DataIndex
'Correct strResult to remove beginning delimiter
strResult = Mid(strResult, Len(sDelimiter) + 2)
Else
'Found not to be an array, range object, or collection
'Simply set the result = varData
strResult = varData
End If
'Output result
ConcatAll = strResult
End Function
Bookmarks