I am working with an array of 2D arrays in Excel VBA. I have a function...
Public Function constructStack(vbr() As Variant, hr As Integer) As stack
Where stack is a class I made. I have another function, in which I am calling constructStack from. here is the call:
Set stacks(i) = stack(i).constructStack(vbr(i), i)
vbr happens to be an array of 2D arrays. Seeing as vbr(i) would refer to a single 2D array of type variant, I'm confused why I'm getting the "Type mismatch: array or user-defined type expected," compile error.
It's almost as if the compiler doesn't realize that vbr() will be filled with 24 2D arrays, which is why it's giving me the compile error. Here is how I Dim vbr:
Dim vbr(1 To 24) As Variant
After declaring vbr, I eventually run this for loop which assigns each element of vbr a 2D array...
vb = GetVBRSorted
For j = 1 To 24
For i = 2 To 2000
If (vb(i, 1)(j) <> "") Then
lastFilleds(j) = i
End If
Next
Next
For j = 1 To 24
ReDim vbrTemp(1 To lastFilleds(j) - 1, 1 To 5)
For i = 2 To lastFilleds(j)
For k = 1 To 5
vbrTemp(i - 1, k) = vb(i, k)(j)
Next
Next
vbr(j) = vbrTemp
Next
GetVBRSorted returns the exact same type as vbr - an array of 2D arrays. If anyone has any input on this issue, it would be much appreciated.