+ Reply to Thread
Results 1 to 5 of 5

Automate Tab Names in a workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    68

    Automate Tab Names in a workbook

    Hi,

    Is it possible to have a set of values on one worksheet and have them come up as tab names on following worksheets. For example, on worksheet 1, I have a list of countries viz. UK, France, Germany, Spain and Italy on cells A1:A5. Once I run the macro (I guess it has to be a macro), I need it to check that there are no tabs by that name and then create a blank worksheet with a tab name for the said country (if the country tab already exists, then ignore).
    In the above example, I will then end up with 6 tabs with tab names 1, UK, France, Germany, Spain, Italy.

    Appreciate your help.

    Rgds

    Krishna

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,298

    Re: Automate Tab Names in a workbook

    Sub MakeSheets()
        Dim c As Range
        Dim strN As String
        
        On Error GoTo CreateSheet
        With Worksheets("1")
            For Each c In .Range(.Range("A1"), .Cells(.Rows.Count, "A").End(xlUp))
                If c.Value <> "" Then strN = Worksheets(c.Value).Name
            Next c
        End With
        Exit Sub
        
    CreateSheet:
        Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = c.Value
        Resume
    End Sub
    Last edited by Bernie Deitrick; 07-09-2015 at 12:35 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Automate Tab Names in a workbook

    Thanks, Bernie..works very well. How do we close it off, if we want the macro to return us to tab 1 cell A1?

    Really appreciate your help..

    Cheers

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,298

    Re: Automate Tab Names in a workbook

    Here you go...

    Sub MakeSheets()
        Dim c As Range
        Dim strN As String
        
        On Error GoTo CreateSheet
        With Worksheets("1")
            For Each c In .Range(.Range("A1"), .Cells(.Rows.Count, "A").End(xlUp))
                If c.Value <> "" Then strN = Worksheets(c.Value).Name
            Next c
            .Activate
            .Range("A1").Select
        End With
    
        Exit Sub
        
    CreateSheet:
        Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = c.Value
        Resume
    End Sub

  5. #5
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Automate Tab Names in a workbook

    Thanks, Bernie...works great.

+ 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] Copy Values From Each Workbook in Folder to a Single Sheet in New Workbook +Workbook names
    By Arsham24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2012, 07:42 PM
  2. Automate new sheets in workbook
    By officespace in forum Excel General
    Replies: 12
    Last Post: 03-24-2011, 06:35 AM
  3. Automate new workbook
    By DStrad in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 02-17-2009, 09:45 AM
  4. automate copy and paste whole workbook to new workbook
    By Leslie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2005, 12:05 PM
  5. Automate defining names
    By Johnny in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2005, 11:06 AM

Tags for this Thread

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