Hi Jakila23
Let your data will be in sheet1 in column A
Try this code for delete rows you need. Copy it to Module and start delete_rows()
Sub delete_rows()
Dim allow
Dim forDelete As New Collection 'a list of rows for delete
allow = Array("JAN", "APR", "JUL", "OCT") 'this months will stay
For r = 1 To Sheets("Sheet1").UsedRange.Rows.Count
If in_array(allow, Left(Sheets("sheet1").Cells(r, 1).Value, 3)) = -1 Then 'if month is not in array then will be take as row for delete
forDelete.Add r
End If
Next r
For i = forDelete.Count To 1 Step -1
Sheets("Sheet1").Rows(forDelete(i) & ":" & forDelete(i)).delete shift:=xlUp 'delete rows from last to first
Next i
End Sub
Function in_array(ByRef allow, val As String) As Integer
in_array = -1
For i = 0 To UBound(allow)
If UCase(val) = allow(i) Then
in_array = i
Exit For
End If
Next i
End Function
Best Regards
Bookmarks