I have the following code:
Code:
Sub
Application.ScreenUpdating = False
Dim wshL As Worksheet
Dim wshN As Worksheet
Dim wshP As Worksheet
Set wshP = Worksheets("Activities & Macro")
Dim d As Date
' Set wshL = Worksheets(Worksheets.Count)
' d = DateValue(wshL.Name)
' wshL.Name = Format(d + 1, "mm-dd-yy")
wshL.Copy After:=Worksheets("Activities & Macro")
Set wshN = ActiveSheet
d = DateValue(wshL.Name)
wshN.Name = Format(d + 1, "mm-dd-yy")
Worksheets("Template").Columns("B:D").Copy wshN.Range("A1")
wshN.Range("E2").PivotTable.SourceData = _
wshN.Range("A1").CurrentRegion.Address(, , xlR1C1, True)
ActiveWindow.Zoom = 90
Application.ScreenUpdating = True
End Sub
My file is used for daily productivity & time tracking and is almost working as I'd like. Originally the macro would place the new sheet to the far right of all sheets in the book, but as it's iterated over the last month or so it's getting cumbersome to keep scrolling all the way to the left to the tab with my macro button ("Activities & Macro"). So, I started tinkering with a new file in which only 3 tabs to start: "Template", "Activities & Macro", and "08-05-20".
When I run the macro a new sheet is created right after the Activities & Macro tab as I'd like (this would mitigate the need to keep scrolling left after a new day/date tab is inserted). However, then there's a break down ... Tab 08-05-20 gets renamed as 08-06-20 and the new sheet (inserted after Activities & Macro tab) is named 08-06-20 (2).
If I run macro again I end up with: 08-07-20 (2), 08-06-20, and 08-07-20 so now what was 08-06-20 is now 08-07-20 and the new sheet is 08-07-20 (2). This would iterate perpetually with every new sheet as a duplicate. Also, once the date is set - it should be static; e.g., first date = 08-05-20, next = 08-06-20, next = 08-07-20 so on for time tracking purposes ...
What am I missing? Thanks!
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313859#p313859
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313855#p313855
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313848#p313848
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313843#p313843
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313792#p313792
https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313771#p313771
https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313767#p313767
https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313746#p313746
https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313744#p313744
https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313741#p313741
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313622#p313622
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313575#p313575
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313573#p313573
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313563#p313563
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313555#p313555
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533
https://www.eileenslounge.com/viewtopic.php?f=39&t=40265&p=313468#p313468
https://www.eileenslounge.com/viewtopic.php?f=42&t=40505&p=313411#p313411
https://www.eileenslounge.com/viewtopic.php?f=32&t=40473&p=313384#p313384
https://www.eileenslounge.com/viewtopic.php?f=30&t=40501&p=313382#p313382
https://www.eileenslounge.com/viewtopic.php?f=30&t=40501&p=313380#p313380
https://www.eileenslounge.com/viewtopic.php?f=30&t=40501&p=313378#p313378
https://www.eileenslounge.com/viewtopic.php?f=32&t=40473&p=313305#p313305
https://www.eileenslounge.com/viewtopic.php?f=44&t=40455&p=313035#p313035
https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312889#p312889
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
Bookmarks