Translate

2013年8月26日 星期一

[VBA] Append items to an Array

https://github.com/walter426/VbaUtilities/blob/master/ArrayUtilities.bas

As there is no build-in function to append items to an array in VBA, I made below function to do such thing.

'Append items to an Array
'Append items to an Array
Public Function AppendArray(Array_src As Variant, Array_append As Variant) As String
    Dim FailedReason As String

    Dim i As Long
    
    For i = LBound(Array_append) To UBound(Array_append)
        ReDim Preserve Array_src(LBound(Array_src) To UBound(Array_src) + 1)
        Array_src(UBound(Array_src)) = Array_append(i)
    Next i


Exit_AppendArray:
    AppendArray = FailedReason
    Exit Function

Err_AppendArray:
    FailedReason = Err.Description
    Resume Exit_AppendArray
    
End Function

沒有留言:

張貼留言