Multi Dimensional Array
Dim intI As Integer, intJ As Integer
Dim rng As Range, s as String
Set rng = Worksheets("Calculations").Range("BlackAMatrix")
For intI = 1 To 10
For intJ = 1 To 4
s = s & rng.Cells(intI, intJ) & ", "
Next intJ
Next intI
Worksheets("Calculations").Range("M1").Value = Left(s,len(s)-2)
---------------------------------
---------------------------------
Dim intI as Long, intJ as Long, v as Variant
Dim rng as Range
Set rng = Worksheets("Calculations").Range("BlackAMatrix")
v = split(Worksheets("Calculations").Range("M1").Value ,", ")
rw = lbound(v)
for intI = 1 to 10
for intj = 1 to 4
rng(i,j) = v(rw)
rw = rw + 1
Next
Next
--
Regards,
Tom Ogilvy
"steve" wrote:
I found a post on here about putting contents of an Array into a cell. The
solution was to use the Join Function. I had the same question, but my Array
is multi-dimensional. I've found that the join function only works for
1-dimensional arrays. Below is some code I came up with for
multi-dimensional arrays, but it seems like there might be a better way.
Also, how would I take the string (with comma delimiters) and put it back
into a multi-dimensional array?
Dim intI As Integer, intJ As Integer
Dim rng As Range
Dim BlackAArray(1 To 10, 1 To 4) As Variant
Set rng = Worksheets("Calculations").Range("BlackAMatrix")
For intI = 1 To 10
For intJ = 1 To 4
BlackAArray(intI, intJ) = rng.Cells(intI, intJ)
Next intJ
Next intI
Worksheets("Calculations").Range("M1").Value = ""
For intI = 1 To 10
For intJ = 1 To 4
If intI = 10 And intJ = 4 Then
Worksheets("Calculations").Range("M1").Value =
Worksheets("Calculations").Range("M1").Value & BlackAArray(intI, intJ)
Else
Worksheets("Calculations").Range("M1").Value =
Worksheets("Calculations").Range("M1").Value & BlackAArray(intI, intJ) & ", "
End If
Next intJ
Next intI
thanks,
Steve
|