ChrisFoster
Active Member
- Joined
- Jun 21, 2019
- Messages
- 256
- Office Version
- 365
- Platform
- Windows
Hi,
I have the below code which looks for any dates from current year in column B and deletes those rows. Every time I run this code it will be on data from a specific month but could be different years (so always November but could be November 2000 all the way to November 2019). It seems to work fine when using any month that isn't the current month.
I'm trying to use the code for data from October and it debugs at the below stage. Please can someone help?
Regards,
Chris
I have the below code which looks for any dates from current year in column B and deletes those rows. Every time I run this code it will be on data from a specific month but could be different years (so always November but could be November 2000 all the way to November 2019). It seems to work fine when using any month that isn't the current month.
Code:
Dim c As Range
With Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row)
Set c = .Find(What:=Year(Date), LookIn:=xlFormulas, lookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
.AutoFilter Field:=2, Criteria1:=xlFilterThisYear, Operator:=xlFilterDynamic
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.AutoFilter
End If
End With
I'm trying to use the code for data from October and it debugs at the below stage. Please can someone help?
Code:
.AutoFilter Field:=2, Criteria1:=xlFilterThisYear, Operator:=xlFilterDynamic
Regards,
Chris