vba delete array element

The solution for “vba delete array element” can be found here. The following code will assist you in solving the problem.

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)
ReDim pArray(0)
End If
End If
End Sub

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts