TOP

VBA function: Join

Description

The VBA Join function groups the values of an array into a character string, using (or not) a delimiter.


Join syntax

Join(text)

Or

Join(text, delimiter)

VBA Join example

Concatenate array values to get a single string with all values separated by "/" :

Sub JoinExample1()
    
      array = Array("example", "test", 123, "xlp")
    
      text = Join(array, " / ")
    
      MsgBox text 'Returns: example/test/123/xlp
    
End Sub

If you do not specify a delimiter, the values will be separated by a space:

Sub JoinExample2()
    
      array = Array("example", "test", 123, "xlp")
    
      text = Join(array)
    
      MsgBox text 'Returns: example test 123 xlp
    
End Sub
The reverse function that splits a string into an array is the SPLIT function.