Hello, I have a worksheet where a new worksheet is created each day with todays date as name (Formated as YYMMDD).

I want dates spanning between the first day of the year and tow months back to be deleated. I have tried so many different ways, and this is my current code. Could anyone assist me?





Sub test()

Dim FirstDate As Date
Dim LastDate As Date
Dim ws As Worksheet

FirstDate = DateSerial(Year(Date), 1, 1)
LastDate = DateSerial(Year(Date), Month(Date) - 1, 1)


For Each ws In Worksheets
if ws.Name = FirstDate to LastDate then
ws.Delete
Else
MsgBox "No Worksheets could be found"
End If

Next ws



End Sub