Streamline/resize 数组数组中的数组大小

Streamline/resize array size in array of arrays

我有以下代码:

Function SplitMe(sourceArray As Variant) As Variant
Dim source As Variant, tempArr As Variant
source = sourceArray

If Not IsArray(source) Then _
    Exit Function

Dim r As Integer
Dim parts() As String
Dim splitted As Variant
ReDim splitted(LBound(source) To UBound(source))

For r = LBound(source) To UBound(source)
    parts = VBA.Split(source(r, 1), "\")
    splitted(r) = parts
Next r

到这里为止一切正常:

splitted = Application.Transpose(splitted)
SplitMe = splitted

For r = LBound(splitted) To UBound(splitted)
    Debug.Print uniqueValues(splitted, r)
Next r
End Function

此时我想转置数组。如果拆分数组中的数组大小相同,则效果很好。当我有这样的查询时出现问题:

uniqueValues(splitted, r) 函数需要转置。

我现在想编写一个函数,它可以继续并为不是最大大小的查询增加长度。
在这种情况下 splitted(1) 会给出长度 0 to 9 然后其他 5 个节点需要增加到 0 to 9.

有人手头有这样的功能吗?

以下函数将数组的数组调整为相同的尺寸:

Function oneDimensionArray(tmpArr As Variant, maxDim As Long) As Variant
Dim r As Long, redimArray As Variant
For r = LBound(tmpArr) To UBound(tmpArr)
    redimArray = tmpArr(r)
    If maxDim > UBound(redimArray) Then ReDim Preserve redimArray(LBound(redimArray) To maxDim)
    tmpArr(r) = redimArray
Next r

oneDimensionArray = tmpArr
End Function