Excel VBA - How to Redim a 2D array?

前端 未结 9 2137
闹比i
闹比i 2020-11-30 06:57

In Excel via Visual Basic, I am iterating through a CSV file of invoices that is loaded into Excel. The invoices are in a determinable pattern by client.

I am readin

9条回答
  •  独厮守ぢ
    2020-11-30 07:20

    Here ya go.

    Public Function ReDimPreserve(ByRef Arr, ByVal idx1 As Integer, ByVal idx2 As Integer)
    
        Dim newArr()
        Dim x As Integer
        Dim y As Integer
    
        ReDim newArr(idx1, idx2)
    
        For x = 0 To UBound(Arr, 1)
            For y = 0 To UBound(Arr, 2)
                newArr(x, y) = Arr(x, y)
            Next
        Next
    
        Arr = newArr
    
    End Function
    

提交回复
热议问题