I need help concerning the handling of a type-matrix.
I want to create a matrix to perform certain operations in since that is much faster than doing the same in a normal worksheet. Besides I have several type matrices that operate on each other.
The part I struggle with is how I write the results to a worksheet. The only approach I have so far is to give each type in the matrix to a variant which I write to the worksheet. I guess there must be a more efficient way to write the "container_matrix" to a sheet other than to hardcode but I don't quite get it.
Is it to obvious on how to do this? Is there a way/handle to iterate through the items "container[1,2,3]" without naming them explicitly? Is the whole approach not suitable? I would like to keep the defined types "container1"
Public Type container_data
container1 As Double
container2 As Double
container3 As Double
End Type
Dim container_matrix() As container_data
ReDim container_matrix(5)
For int1 = 0 To 4
container_matrix(int1).container1 = 10
container_matrix(int1).container2 = 15
container_matrix(int1).container3 = 25
'**ignorance starts here:**
Dim var1 As Variant
ReDim var1(5, 3)
var1(int1, 0) = container_matrix(int1).container1
var1(int1, 1) = container_matrix(int1).container2
var1(int1, 2) = container_matrix(int1).container3
Next int1
Worksheets(1).Range("A1:C" & 5) = var1
question from:
https://stackoverflow.com/questions/66065105/vba-iterate-through-type-matrix-and-write-to-worksheet 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…