foolishpiano
New Member
- Joined
- Aug 19, 2016
- Messages
- 28
Hello everyone! I currently have a workbook that is updated daily, and I've created a macro that captures the data and creates a new worksheet in the workbook dated with the current date. I've included what I think is all of the relevant code below (I'm happy to post the full code if that would be helpful as well):
What I'm wondering is: is it possible to add to the code a line that will go through the workbook and hide all worksheets that were created over a week ago? The number of open worksheets is starting to become ridiculous, and does not need to be visible all of the time. This data is just for historical record to be recalled if needed.
Thank you all for your help!
Code:
' Create new worksheet with today's date
Dim szTodayDate As String
szTodayDate = Format(Date, "mmm-dd-yyyy")
On Error GoTo MakeSheet
Sheets(szTodayDate).Activate
Exit Sub
MakeSheet:
Sheets.Add , Worksheets(Worksheets.count)
ActiveSheet.Name = szTodayDate
' Copy table data from FTS to new worksheet
Worksheets("Table Data from FTS").ListObjects("Table_query__1").Range.Copy
ActiveSheet.Range("A1").PasteSpecial Paste:=xlPasteValues
What I'm wondering is: is it possible to add to the code a line that will go through the workbook and hide all worksheets that were created over a week ago? The number of open worksheets is starting to become ridiculous, and does not need to be visible all of the time. This data is just for historical record to be recalled if needed.
Thank you all for your help!