Option 1
Public Sub filter_attempt1()
'# declare
Dim n As Long
Dim intMonth As Integer
'# freeze application user interface
Application.ScreenUpdating = False
'# for worksheet 1
With ThisWorkbook.Worksheets(1)
For n = .Cells(.Rows.Count, "A").End(xlUp).Row To 2 Step -1
'# if a value exists in column A
If LenB(.Cells(n, "A").Value & "") > 0 Then
'# if the month > 2 and < 11 then delete the row
intMonth = CInt(Mid$(.Cells(n, "A").Value, 6, 2))
If intMonth > 2 And intMonth < 11 Then
.Rows(n).Delete
End If
End If
Next n
End With
'# unfreeze
Application.ScreenUpdating = True
MsgBox ("sorta success")
End Sub
option 2
Public Sub filter_attempt2()
'# declare
Dim n As Long
Dim intMonth As Integer
Dim objRange As Range
'# freeze application user interface
Application.ScreenUpdating = False
'# for worksheet 1
With ThisWorkbook.Worksheets(1)
For n = .Cells(.Rows.Count, "A").End(xlUp).Row To 2 Step -1
'# if a value exists in column A
If LenB(.Cells(n, "A").Value & "") > 0 Then
'# if the month > 2 and < 11 then delete the row
intMonth = CInt(Mid$(.Cells(n, "A").Value, 6, 2))
If intMonth > 2 And intMonth < 11 Then
If objRange Is Nothing Then
Set objRange = .Rows(n)
Else
Set objRange = Union(objRange, .Rows(n))
End If
End If
End If
Next n
End With
'# delete
objRange.Delete
'# unfreeze
Application.ScreenUpdating = True
MsgBox ("sorta success")
End Sub
Bookmarks