excel vba array hapus dulu

Public Sub DeleteElementFromArray(ByRef pArray As Variant, ByVal pIndex As Long)
    Dim index As Integer
    If pIndex >= LBound(pArray) And pIndex <= UBound(pArray) Then
        For index = pIndex + 1 To UBound(pArray)
            pArray(index - 1) = pArray(index)
        Next
        If UBound(pArray) - LBound(pArray) > 0 Then
            ReDim Preserve pArray(UBound(pArray) - LBound(pArray) - 1)
        Else
            ReDim pArray(0)
        End If
    End If
End Sub
VasteMonde