1次元x1次元配列を2次元配列に変換します。
Dictionaryに1次元配列を溜めておいて、
最後に2次元配列に変換する時に使用することが多いです。
いやむしろ、その為だけの関数かも...
例:DataArray = fArray_Dim1x1_to_Dim2(Dic.Items)
Private Function prSample()
Dim Dic As New Scripting.Dictionary
Dic.Item(Dic.Count) = Array(1, 2)
Dic.Item(Dic.Count) = Array(2, 3)
Dim DataAry As Variant
DataAry = fArray_Dim1x1_to_Dim2(Dic.Items)
End Function
Private Function fArray_Dim1x1_to_Dim2(Array1x1 As Variant) As Variant
'1次元x1次元の配列を2次元配列に変換する(Lite版)
'使用例:DictionaryのItemにデータ(1次元配列)を溜めておき、2次元配列に変換する
If IsArray(Array1x1) = False Then Exit Function
'開始・終了を取得
Dim Row_L As Long
Dim Row_U As Long
Row_L = LBound(Array1x1, 1)
Row_U = UBound(Array1x1, 1)
If (Row_U - Row_L + 1) = 0 Then Exit Function
'最初の1次元配列を取得
Dim Ary1 As Variant
Ary1 = Array1x1(Row_L)
If IsArray(Ary1) = False Then Exit Function
'1次元配列の開始・終了を取得(開始・終了列)
Dim Col_L As Long
Dim Col_U As Long
Col_L = LBound(Ary1)
Col_U = UBound(Ary1)
'2次元配列を準備
Dim Ary2 As Variant
ReDim Ary2(Row_L To Row_U, Col_L To Col_U)
'各1次元配列を2次元配列に格納していく
Dim Row As Long
For Row = Row_L To Row_U
Ary1 = Array1x1(Row)
If IsArray(Ary1) = False Then Exit Function
Dim Col As Long
For Col = Col_L To Col_U
Ary2(Row, Col) = Ary1(Col)
Next
Next
fArray_Dim1x1_to_Dim2 = Ary2
End Function