PDA

Click to See Complete Forum and Search --> : 2 dimensional join function


westconn1
Feb 24th, 2008, 05:09 AM
this is to simply join a 2 dimensional array with 2 delimiters
accepts any type of array, returns a string
Function join2(myarr, chr1 As String, chr2 As String) As String
Dim mystr As String, i As Integer, j As Integer
mystr = ""
For i = LBound(myarr, 1) To UBound(myarr, 1)
For j = LBound(myarr, 2) To UBound(myarr, 2) - 1
mystr = mystr & CStr(myarr(i, j)) & chr1
Next
mystr = mystr & CStr(myarr(i, j)) & chr2
Next
join2 = mystr
End Function

call like
Debug.Print join2(myarr, vbTab, vbNewLine)

sat19
Mar 21st, 2012, 10:12 AM
Thank youwestconn1

sat19
Mar 21st, 2012, 10:14 AM
My apologies, posted my code on wrong thread