0

The core of my problem is that I have to work with arrays of different lengths, decided to use a class variable. Yet, I cannot automate the change between the subclasses (see code: U1..U3). Is there a way to do so? If not, is there another way to work with a 2D matrix where the number of rows is changing from column to column? With Matlab background, I also tried "Application.Evaluate" without success. Every help is appreciated.

Option Base 1
Option Explicit

Public Type UnitT
U1() As Double
U2() As Double
U3() As Double
End Type
Dim Resu() As UnitT

Sub test()
Dim Nul() As Variant, ArrayIn() As Double, i As Integer

Nul = [{5,10,15}]



ReDim Resu(2, 1)
For i = 1 To 2
    ReDim Resu(i, 1).U1(Nul(i))
Next i

'that would be the idea or something similar
'ReDim Resu(2, 1)
'For i = 1 To 2
'    For j = 1 To 3 ' Ubound(U1..U3)
'    ReDim Resu(i, 1).U(j)(Nul(i))
'    Next j
'Next i
  • Is this something you are looking for? https://stackoverflow.com/questions/9435608/how-do-i-set-up-a-jagged-array-in-vba BTW, you are using *Type*, not *Class*, which is different two concepts in VBA... – Kosuke Sakai Nov 15 '19 at 08:26
  • thank you, I did look for jagged arrays and I did use type instead of class variable – user11479697 Nov 18 '19 at 06:08
  • And did that help to solve your question? It would be possible to achieve your goal by defining `U(1 To 3) As Variant` instead of `U1(), U2(), U3()`, `ReDim` a variable `Double()`, and assign it to every `U(j)`. – Kosuke Sakai Nov 18 '19 at 06:17

0 Answers0