' Element to delete
iDelete = 5 ' Number of elements before deletion nElements = UBound(Array) ' Replace iDelete with last item in array Array(iDelete) = Array(nElements) ' Use ReDim Preserve to shrink array by one ReDim Preserve Array(LBound(Array) To nElements - 1) Conventional wisdom suggests that to delete an array element, you must move up all the subsequent elements to close the "gap" left by the deleted item. However, if the sequence of the elements isn't significant (as in an unsorted array), this algorithm quickly deletes an item: |