VBA Join Function
Join Description
Joins a number of substrings into a single string.
Simple Join Examples
1 2 3 4 5 6 7 8 9 |
Sub Join_Example() Dim strFullName As String Dim arrName(0 To 2) As String arrName(0) = "Michael" arrName(1) = "Pauling" strFullName = Join(arrName) MsgBox strFullName End Sub |
This will display as following.
Join Syntax
In the VBA Editor, you can type “Join(” to see the syntax for the Join Function:
The Join function contains 2 arguments:
SourceArray: 1d array containing substrings to be joined.
Delimiter: [Optional] Delimiter. If omitted, the space character (” “) is used.
Examples of Excel VBA Join Function
1 2 3 4 5 6 7 8 |
Sub JoinArray_Example1() Dim strFullPath As String Dim arrPath(0 To 2) As String arrPath(0) = "C:" arrPath(1) = "Users" arrPath(2) = "Public" strFullPath = Join(arrPath, "\") End Sub |
Result: C:\Users\Public
1 2 3 |
Sub JoinArray_Example2() MsgBox Join(Array("A", "B", "C"), ", ") End Sub |
Result: “A, B, C”
VBA Coding Made Easy
Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!
Learn More!