+ Reply to Thread
Results 1 to 14 of 14

Automaticly naming file tabs

Hybrid View

  1. #1
    Registered User
    Join Date
    09-22-2013
    Location
    New England
    MS-Off Ver
    Excel 2007, 2010 & 2013
    Posts
    24

    Automaticly naming file tabs

    I keep re-creating tabs and rename them to the date I created them, up to 26/year. I used a =cell("Filename") formula from another thread that pulls the tab name and combines it with the file location. I also found a thread that re-creates a PO tab by double clicking on a cell. I thought that could work but if it could name the tab with the date, that would be complete. Unfortunately I do not have a file with me to load. I'm not good with VB but can do nested IF formulas.

    Thoughts and suggestions? Thanks.

  2. #2
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    508

    Re: Automaticly naming file tabs

    Can you upload and example file

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Automaticly naming file tabs

    Hi,

    One way would be to use the Workbook sheet double click event. e.g.

    Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    ActiveSheet.Name = Replace(Range("A1"), "/", "_")
    End Sub
    Here the value in A1 will become the sheet tab name. If that happens to be a date then any "/" date separators will be replaced with a "_"
    If you always want today's date then the line could simply be

    ActiveSheet.Name = Replace(Date, "/", "_")
    Of course you would get an error if you double clicked when on another sheet on the same day.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    508

    Re: Automaticly naming file tabs

    Are you creating Tabs of a Template

  5. #5
    Registered User
    Join Date
    09-22-2013
    Location
    New England
    MS-Off Ver
    Excel 2007, 2010 & 2013
    Posts
    24

    Re: Automaticly naming file tabs

    Template?? If you mean making a coping from a previous dated tab, then yes. And the new tab is what I am looking to name with the current date. I'm going to fool around with RB's code and see if I can get it to work.

    Thanks.

  6. #6
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    508

    Re: Automaticly naming file tabs

    What is your Template Sheet Called

  7. #7
    Registered User
    Join Date
    09-22-2013
    Location
    New England
    MS-Off Ver
    Excel 2007, 2010 & 2013
    Posts
    24

    Re: Automaticly naming file tabs

    The previous date. Any date. Once every 2 weeks I need to re-create the previous dated tab.

  8. #8
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    508

    Re: Automaticly naming file tabs

    Hi this should put you on the right path, most of the code was written by Leith Ross have a look.

    the SHEET LIST Tab records all the dates and is used to see if the date has been used before.

    Hope it helps you out

    Book2.xls

  9. #9
    Registered User
    Join Date
    09-22-2013
    Location
    New England
    MS-Off Ver
    Excel 2007, 2010 & 2013
    Posts
    24

    Re: Automaticly naming file tabs

    This is good but not what I had in mind. I will play around with all of this for a few days, figure some stuff out and report back. Thanks for the help.

    Looking forward to posting additional questions and troubleshooting with more advanced Excel users.

  10. #10
    Registered User
    Join Date
    09-22-2013
    Location
    New England
    MS-Off Ver
    Excel 2007, 2010 & 2013
    Posts
    24

    Re: Automaticly naming file tabs

    Attached is a basic file that has some info that my be of more help.
    Attached Files Attached Files

  11. #11
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    508

    Re: Automaticly naming file tabs

    this should put you in the right direction.

    this will create a new workbook and name it with your date

    Sub SaveSheet()
        ActiveSheet.Copy
        With ActiveSheet.UsedRange
            .Copy
            .PasteSpecial xlValues
            .PasteSpecial xlFormats
        End With
        Application.CutCopyMode = False
        ActiveWorkbook.SaveAs "" & Format(Range("D3"), "mm-d-yyyy")
    End Sub

  12. #12
    Registered User
    Join Date
    09-22-2013
    Location
    New England
    MS-Off Ver
    Excel 2007, 2010 & 2013
    Posts
    24

    Re: Automaticly naming file tabs

    Close, so close. I think my lack of VBA experience is the real hold up here. I was able to insert the macro, attach it to a button, but then I get a DEBUG popup and a new window file opens up with the correct dated tab. I was hoping to get the new dated tab into the current file.

    Thanks

  13. #13
    Forum Contributor
    Join Date
    09-24-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Automaticly naming file tabs

    Hi,

    Would this help you ..
    Sub Button1_Click()
    
    
    Application.ScreenUpdating = False
    
        Sheets("Sheet1").Select
        Sheets("Sheet1").Copy After:=Sheets(2)
        Sheets("Sheet1 (2)").Select
        Sheets("Sheet1 (2)").Name = Replace(Date, "/", "_")
        With ActiveSheet
        Randomize
        .Tab.Color = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
    End With
        Sheets("Sheet1").Select
    
    
    Application.ScreenUpdating = True
    
    
    End Sub
    The above code would copy sheet1 and create a new tab with the date and change the color of the tab at random. all you would have to do is attach the code to a button and change the sheet name to what you need.

    Hope this helps..

  14. #14
    Registered User
    Join Date
    09-22-2013
    Location
    New England
    MS-Off Ver
    Excel 2007, 2010 & 2013
    Posts
    24

    Re: Automaticly naming file tabs

    The random colors is a very cool feature. I still need to figure this out within VBA, having trouble but have not stopped trying.


    WWWWHHOOOOOO!

    Solved, thanks.
    Last edited by Mechanical Pencil; 10-26-2013 at 07:55 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Naming Tabs
    By Harrytheb in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-10-2013, 01:35 PM
  2. Naming tabs
    By Amh in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 08-26-2012, 10:11 PM
  3. Naming the Tabs
    By inayat in forum Excel General
    Replies: 4
    Last Post: 09-19-2011, 05:19 AM
  4. Naming Tabs
    By ebro in forum Excel General
    Replies: 3
    Last Post: 07-13-2006, 06:10 PM
  5. naming tabs
    By Jeff in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-06-2006, 12:45 AM

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