-
Solved: Manipulation on Array elements
Dear all, I have an array of strings, like:
[VBA]
dim StringArray(5) as string
StringArray(1) = "a"
StringArray(2) = "b"
StringArray(3) = "c"
StringArray(4) = "d"
StringArray(5) = "e"
[/VBA]
here the array length (in present case, which is '5') is basically a variable. Now what I want is to add all the array elements and put them as: "a, b, c, d, e".
Is there any direct way to achieve that?
Thanks and regards,
-
[vba]sn=split("a|b|c|d|e","|")[/vba]
or
[VBA]sn = [index(char(96 +row(1:5)),)][/VBA]
or
[VBA]
sn = [transpose(char(96 +row(1:5)))]
[/VBA]
-
Use Join:
[VBA]Sub luxation()
Dim StringArray(1 To 5) As String
Dim st As String
StringArray(1) = "a"
StringArray(2) = "b"
StringArray(3) = "c"
StringArray(4) = "d"
StringArray(5) = "e"
st = Join(StringArray, ", ")
MsgBox st
End Sub
[/VBA]
-
Thanks snb and GarysStudent for your help. GarysStudent's suggestion really served my purpose. Also thanking snb for looking into my problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules