I have a question about the code in this thread
In that thread, is this code
Sub ClearOldData()
Application.ScreenUpdating = False
Dimi As Long
With Sheets("Data")
For i = 2 To LastRow Step -1
If Int(Date - Cells(i, "F").Value) > 179 Then
.Rows(i).Delete
End If
Next i
End With
Application.ScreenUpdating = True
End Sub
The problem I am running into is that when I run this code, I receive the following error:
Compile error: Statement invalid outside Type block
Upon first look, the Dim looks to be incorrect as it is listed as Dimi and I can find no reference to VBA using something like that. I changed it to Dim and it still gives the error. This code appears to be correct in all I have researched on this, but I am scratching my head over where the hiccup is at. Anyone have an idea where it is going sideways at?
Thanks
Subdo you define andSet LastRow? Also, fully qualifyCells(i, "F").Valueby adding a.like.Cells(i, "F").Value. I would recommned to switch toIf DateDiff("d", .Range("F" & i).Value, Date) > 179 Then