同じ配列へのアクセスを必要とする2つの異なる関数があります(配列は定数ではなく、シート内のセル内で関数が使用されるたびに編集および追加されます)。関数を使用した配列の再利用
この配列を両方で使用できるようにしたいと考えています。配列は多次元(または、私のコードで試したような複数の要素を持つことができるUDTである必要があります)でなければならず、動的にサイズを変更できる必要があります。ここに私が持っているいくつかのサンプルコード(少し編集)がありますが、それは適切に動作していないようです。
Option Base 1
Private Type PathsArray
Nodes() As String
End Type
' Instantiate the global array
Dim Paths(1 To 1) As PathsArray
Function SETTWENTY()
' Increase size of the array, preserving the current elements already inside it
ReDim Preserve Paths(1 To UBound(Paths) + 1)
' Make the inner array be 20 elements long
ReDim Preserve Paths(UBound(Paths)).Nodes(1 to 20)
' Return something random
GETPATH = UBound(Paths)
End Function
Function SETTHIRTY()
' Increase size of the array, preserving the current elements already inside it
ReDim Preserve Paths(1 To UBound(Paths) + 1)
' Make the inner array be 30 elements long
ReDim Preserve Paths(UBound(Paths)).Nodes(1 to 30)
' Return something random
GETPATH = UBound(Paths)
End Function
これはなぜ機能しないのですか?
詳細な説明をいただきありがとうございます。私はあなたの助けを借りて問題を整理することができました! – Steve