karinfromsweden
New Member
- Joined
- Oct 30, 2018
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
Hey all,
I have this neat little macro that runs on every start of a sheet. It's (supposed to be) pretty simple, checking for rows that are older than 180 days and then deleting part of the content of the row. My boss was so happy over this GDPR-compliant macro.
But then a few days ago it started giving "run time error 13 Type mismatch".
I have doublechecked that the column only holds correctly formatted dates. And from what I can see, the macro works. So why does it give an error?
Any help would be dearly appriciated! Thank you!
I have this neat little macro that runs on every start of a sheet. It's (supposed to be) pretty simple, checking for rows that are older than 180 days and then deleting part of the content of the row. My boss was so happy over this GDPR-compliant macro.
But then a few days ago it started giving "run time error 13 Type mismatch".
I have doublechecked that the column only holds correctly formatted dates. And from what I can see, the macro works. So why does it give an error?
Any help would be dearly appriciated! Thank you!
Code:
Sub ClearCells()
Dim Cel As Range, Ws As Worksheet
Set Ws = Sheets("START")
For Each Cel In Ws.Range("A5", Ws.Range("A" & Rows.Count).End(xlUp))
If DateDiff("d", Cel, Date) > 180 And Cel.Offset(, 0) <> "" Then Cel.Offset(, 6).Resize(, 3).ClearContents
Next Cel
End Sub