VBA Function: Join
The VBA function Join combines the values of an array into a string, with an optional delimiter.
Usage:
Join(array)
or
Join(array, delimiter)
Example of Usage
Concatenating the values of the array to obtain a single string with all values separated by / :
Sub example()
myArray = Array("example", "test", 123, "xlp")
myText = Join(myArray, " / ")
MsgBox myText 'Returns: example / test / 123 / xlp
End Sub
If you don't specify a delimiter, the values will be separated by a space:
Sub example()
myArray = Array("example", "test", 123, "xlp")
myText = Join(myArray)
MsgBox myText 'Returns: example test 123 xlp
End Sub
The inverse function that divides a string into an array is the Split function.