S
steve
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
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