Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function ArrayDelete(ByRef oArray As Variant, ByVal indexToDelete As Long) As Variant
On Error GoTo ErrHandler
Dim index As Long
Dim tmpArray As Variant
If indexToDelete < LBound(oArray) Or indexToDelete > UBound(oArray) Then
Err.Raise 9
End If
ReDim tmpArray(LBound(oArray) To (UBound(oArray) - 1))
For index = indexToDelete To (UBound(oArray) - 1)
oArray(index) = oArray(index + 1)
Next index
For index = LBound(tmpArray) To UBound(tmpArray)
tmpArray(index) = oArray(index)
Next index
ArrayDelete = tmpArray
ExitHere:
Exit Function
ErrHandler:
MsgBox Err & "-" & Err.Description
ArrayDelete = oArray
Resume ExitHere
End Function
Sub TestArrayDelete(ByVal index As Long)
Dim oldArray(1 To 8) As String
Dim newArray As Variant
Dim l As Long
oldArray(1) = "1-Tek"
oldArray(2) = "2-Tips"
oldArray(3) = "3-Unites"
oldArray(4) = "4-People"
oldArray(5) = "5-From"
oldArray(6) = "6-Around"
oldArray(7) = "7-The"
oldArray(8) = "8-Globe"
newArray = ArrayDelete(oldArray, index)
Erase oldArray
For l = LBound(newArray) To UBound(newArray)
Debug.Print newArray(l)
Next l
End Sub