I am trying to create an array which with UDTs subarary inside, and the code as below, But run with the error, "Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions". if anyone has a suggestion?
Option Explicit
Type udtA
A As Integer
B As Integer
C As Integer
End Type
Sub Main()
test
End Sub
Function test()
Dim A() As Variant
Dim B() As udtA, intRun As Integer
Dim udtARun As udtA
ReDim A(0)
ReDim B(2)
intRun = 1
Do While intRun <= UBound(B) + 1
With udtARun
.A = 1 * intRun
.B = 100 * intRun
.C = 10000 * intRun
End With
B(intRun - 1) = udtARun
intRun = intRun + 1
Loop
A(0) = B
End Function