Very strange. When I run this piece of the macro by itself, it works, not problems, no error. When I run this as part of a larger macro I get below error message at the step where all rows that contain TRUE in column J are to be deleted. Please help me!![]()
Run-time error '1004': No cells were found
Sub delete_old_dates()
Dim X As Long, MinDateColO As Date, DateChanged As Boolean, Arr As Variant
MinDateColO = WorksheetFunction.Min(Worksheets("tis").Columns("O"))
With Worksheets("ClearPar")
Arr = Intersect(.UsedRange, .Columns("J"))
For X = 1 To UBound(Arr)
If Arr(X, 1) < MinDateColO Then
Arr(X, 1) = True
If Not DateChanged Then DateChanged = True
End If
Next
If DateChanged Then
Intersect(.UsedRange, .Columns("J")) = Arr
' the next line is where the error takes place,"Run-time error '1004': No cells were found". All the rows that contain TRUE in column "J" are supposed to be deleted.
Columns("J").SpecialCells(xlConstants, xlLogical).EntireRow.delete
End If
End With
End Sub
Bookmarks