I am trying to delete an activesheet based on the current date and have not been able to find any help in VBA help on this.
The background is that I have a number of sheets and when I reach the next month, I would like the oldest sheet deleted and a new sheet created. I will work on the sheet names and identity of the date and sheet myself, but my VBA code to delete the sheet will be something like :
Sub TimeBomb()
TimeValue1 = Now()
If TimeValue1 < DateValue("January 1, 2004") Then
Exit Sub
Else
ActiveWindow.SelectedSheets.Delete
End If
End Sub
My problem is that when I run this in January, the message appears: "Selected sheets will be permanently deleted" and I have to click on "Yes".
Is there a way to avoid this message, or have the macro choose "Yes" for me?
The background is that I have a number of sheets and when I reach the next month, I would like the oldest sheet deleted and a new sheet created. I will work on the sheet names and identity of the date and sheet myself, but my VBA code to delete the sheet will be something like :
Sub TimeBomb()
TimeValue1 = Now()
If TimeValue1 < DateValue("January 1, 2004") Then
Exit Sub
Else
ActiveWindow.SelectedSheets.Delete
End If
End Sub
My problem is that when I run this in January, the message appears: "Selected sheets will be permanently deleted" and I have to click on "Yes".
Is there a way to avoid this message, or have the macro choose "Yes" for me?