+ Reply to Thread
Results 1 to 6 of 6

Macro to display current date on tab

  1. #1
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    60

    Macro to display current date on tab

    I have to do daily balancing of the general ledger reports and I have to do the same steps for 4 companies every single morning. I would love to be able to set up a macro to do this. The steps that I take every morning is:

    Right click on current tab date, choose "move or copy", then rename the new tab to today's date. Then I change the run date cell so that it is today's date.

    Then I go back to the tab that I copied the information from and I do a copy/paste special values to get just values and no formulas.

    My current macro I have implemented does most of that stuff, except I am having trouble with the changing of the Run Date cell to today's date and also the tab sheet changes to the correct date, but I did it again to test it and it said I cannot have the same tab named twice, so this will be a problem tomorrow and onward. My current macro is as follows:

    Sub Macro2()
    '
    ' Macro2 Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+B
    '
    Sheets("10-06").Select
    Sheets("10-06").Copy After:=Sheets(37)
    Sheets("10-06 (2)").Select
    Sheets("10-06 (2)").Name = "10-07"
    Sheets("10-06").Select
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets("10-07").Select
    Range("D10").Select
    ActiveCell.FormulaR1C1 = "10/7/2011"
    Range("D11").Select
    End Sub
    Any help is greatly appreciated. If not, I suppose I could just use my macro and just continue to just change the dates manually on the new tab and new tab's run date cell.
    Last edited by paperwings25; 10-07-2011 at 12:28 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,756

    Re: Macro to display current date on tab

    Please note that your code example should be in CODE tags. You should change that before anyone can offer a solution.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,756

    Re: Macro to display current date on tab

    Close, not quite but better.

    Try:

    Please Login or Register  to view this content.

    Regards

  4. #4
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    60

    Re: Macro to display current date on tab

    I think this works for the most part, except that the tab's date is in a different format than what I have. I've been going with just a general "10-7" format. A mm/dd type. I ended up getting it to work with 10.07 rather than 10-07. Is there any way to code it to do that way?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,756

    Re: Macro to display current date on tab

    Yes, not much to change:

    Please Login or Register  to view this content.

    Regards

  6. #6
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    60

    Re: Macro to display current date on tab

    I did this exact change before I posted on here to ask, and it gave me some authentication error. It works now, though. Weird. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1