Remove Array Element by Content
Remove an element from array by Content.
'removes only the first instance of the array that matches the value
'if you know the upper/lower limits of the array, just use them
'TestValue and MyArray should have the same Type
Dim i As Long , j As Long
For i = Lbound (MyArray) To Ubound (MyArray) - 1
If MyArray(i) = TestValue Then
For j = i To Ubound (MyArray) - 1
MyArray(j) = MyArray(j + 1)
Next j
Exit For
End If
Next i
Special Instructions
This content is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.