Results 1 to 10 of 10

Thread: Problem inserting new worksheet in Excel daily time tracker w/ date format (at specific location in book)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Aug 2020
    Posts
    5
    Rep Power
    0

    Problem inserting new worksheet in Excel daily time tracker w/ date format (at specific location in book)

    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
    Last edited by DocAElstein; 03-01-2024 at 02:11 PM.

Similar Threads

  1. Extract Time in 24H format from Date and time.
    By zorro in forum Excel Help
    Replies: 3
    Last Post: 09-01-2016, 07:20 PM
  2. Replies: 7
    Last Post: 08-25-2016, 04:14 PM
  3. inserting date
    By CORAL in forum Excel Help
    Replies: 5
    Last Post: 08-05-2014, 02:22 AM
  4. Inserting time in spreadsheet
    By papabill in forum Excel Help
    Replies: 17
    Last Post: 10-25-2013, 01:34 PM
  5. work book format
    By Prabhu in forum Excel Help
    Replies: 1
    Last Post: 03-25-2012, 10:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •