Could you help with VBA code to find and delete the right Worksheet?
I have a report that requires that five days' worth of data be saved on five separate tabs, one tab per day. Those tabs are automatically created and named by my VBA code. However, I am having trouble identifying the sheet that's six days old and deleting it.
This code creates and renames my sheet to the current date.
However, my problem is that I am not able to write the code to:
1 - count back six days to identify the correct date (NameToday-6 hasn't worked, but I've tried to do a simple formula in the sheet itself and then read that value with my code.)
2 - format the Worksheet.Name to be in the correct format.
3 - Delete the sheet with the matching name.
I'd appreciate any suggestions you can offer! Clearly I'm out of my element when writing code, but I'm trying to learn.
Thanks!
I have a report that requires that five days' worth of data be saved on five separate tabs, one tab per day. Those tabs are automatically created and named by my VBA code. However, I am having trouble identifying the sheet that's six days old and deleting it.
This code creates and renames my sheet to the current date.
VBA Code:
Sheets.Add After:=ActiveSheet
NameToday = Format(Date, "MM-DD-YYYY"
ActiveSheet.Name - NameToday
However, my problem is that I am not able to write the code to:
1 - count back six days to identify the correct date (NameToday-6 hasn't worked, but I've tried to do a simple formula in the sheet itself and then read that value with my code.)
2 - format the Worksheet.Name to be in the correct format.
3 - Delete the sheet with the matching name.
I'd appreciate any suggestions you can offer! Clearly I'm out of my element when writing code, but I'm trying to learn.
Thanks!