Thursday, 21 May 2015

How to Join an Array of Strings into a single String in VBA

VBA Join Function
The VBA 'Join' Function joins the Substrings contained in an array, and returns a String by Concatenating the  Substrings separated by a specified delimiter.

Syntax :
StringName = join(Array Input, Delimiter)

Here , Array Input is the array that you want to place into a string.

Delimiter is an optional parameter that indicates what you want to place between elements are added to the string. By default this parameter is set to "".

Sub Split_Store_In_Array()

Dim MyStr(6) As String

'Array Input as follows
MyStr(0) = "This"
MyStr(1) = "Is"
MyStr(2) = "What"
MyStr(3) = "I"
MyStr(4) = "Want"
MyStr(5) = "To"
MyStr(6) = "Store"

'Concatenating/Joining all Arrary Values so as to form a single String
Conc_Str = Join(MyStr, "_")

MsgBox Conc_Str

End Sub

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your open Feedback only related to this Blog Posts. Please note that I cannot respond to the Anonymous Comments.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts