Option Base 1
'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
'★2次元配列の1次元目の要素数を増やす
'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Public Function zfRedimPreserveArray(ByVal arr As Variant, ByVal rowNum As Long)
Dim tempArr() As Variant
tempArr = WorksheetFunction.Transpose(arr)
ReDim Preserve tempArr(UBound(tempArr, 1), rowNum)
zfRedimPreserveArray = WorksheetFunction.Transpose(tempArr)
End Function
Public Function zfRedimPreserveArray2(ByVal arr As Variant, ByVal rowNum As Long)
Dim tempArr() As Variant
Dim i As Long
If rowNum = 1 Then
ReDim tempArr(1, UBound(arr, 2))
For i = 1 To UBound(arr, 2)
tempArr(1, i) = arr(1, i)
Next i
zfRedimPreserveArray = tempArr
Else
tempArr = WorksheetFunction.Transpose(arr)
ReDim Preserve tempArr(UBound(tempArr, 1), rowNum)
zfRedimPreserveArray = WorksheetFunction.Transpose(tempArr)
End If
End Function
コメント