Option Explicit
Function Delete3(Arr As Variant) As Variant
Dim i As Integer
For i = LBound(Arr) To UBound(Arr)
If i > UBound(Arr) Then Exit For
If Arr(i) = 3 Then
Do
Dim j As Integer
For j = i To UBound(Arr) - 1
Arr(j) = Arr(j + 1)
Next j
If LBound(Arr) = UBound(Arr) Then
Delete3 = Empty
Exit Function
End If
ReDim Preserve Arr(LBound(Arr) To UBound(Arr) - 1)
If i > UBound(Arr) Then Exit For
Loop While Arr(i) = 3
End If
Next i
Delete3 = Arr
End Function
Sub Test()
Delete3 (Array(3, 3, 3, 3, 1, 3, 7, 3, 3, 3, 9, 3, 3))
Delete3 (Array(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3))
Delete3 (Array(1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3))
Delete3 (Array(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1))
End Sub