how do I join multi dimentional arrays

M

MK

I am trying to Join a 2 dimensional array into a string with comas as
deliminators in VB on excel... ie. mystring=join(multiarry)

multiarry being a 2 dimentional array
 
P

Per Jessen

Hi

See this example:

Sub JoinData()
Dim MyArray(1 To 2, 1 To 10)
Dim MyString As String

For r = 1 To 2
For c = 1 To 10
MyArray(r, c) = r * c
Next
Next

For c = LBound(MyArray, 1) To UBound(MyArray, 1)
For r = LBound(MyArray, 2) To UBound(MyArray, 2)
If MyString = "" Then
MyString = MyArray(c, r)
Else
MyString = MyString & ", " & MyArray(c, r)
End If
Next
Next
Debug.Print MyString
End Sub

Hopes it helps

Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top