+ Reply to Thread
Results 1 to 4 of 4

Auto Complete tab names

Hybrid View

  1. #1
    Registered User
    Join Date
    10-24-2007
    Posts
    2

    Auto Complete tab names

    After reviewing a lot of questions regarding Excel in this forum, my question is very simple

    In a document, the tabs at the bottom I individually rename for each month (Jan-Dec). I thought I remember learning a trick way back in the day where if you start the first tab as JAN, there was a way to autocomplete the rest of the tabs for the following months. Does this sound familiar to anyone? I've been racking my brain trying to figure it out but I am not getting anywhere. Help would be GREATLY appreciated.

    Regards,

    Janelle

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    If your workbook has 12 sheets already this macro would rename them for you

    Where to add code

    http://www.bettersolutions.com/excel...C216621011.htm

    Sub NameSheetTabs()
    Dim MyArr As Variant
    Dim i As Long
    
    MyArr = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    
    For i = LBound(MyArr) To UBound(MyArr)
    On Error Resume Next
    If Err.Number <> 0 Then
                MsgBox Err.Number & " " & Err.Description
                Err.Clear
              End If
    Sheets(i + 1).Name = MyArr(i)
    Next i
    On Error GoTo 0
    End Sub

    VBA Noob
    Last edited by VBA Noob; 10-24-2007 at 05:57 PM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-24-2007
    Posts
    2

    Wow

    Ok, you can say I am still in the "beginning" stages of Excel and I haven't quite figured out the macro thing yet. I have used files that already have the macro in it but I don't know anything else about them. Looks like I need to take another course!

    Theres not any other way to do it?

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    You could set up a template if you need to do it a lot

    http://office.microsoft.com/en-us/ex...292861033.aspx

    or maybe this event macro. Right click each sheet and select view code and paste in the below then Sheet will rename to value in A1

    Private Sub Worksheet_Change(ByVal Target As Range)
             If Target.Address = "$A$1" Then
              On Error Resume Next
              ActiveSheet.Name = Range("A1").Value
              If Err.Number <> 0 Then
                MsgBox Err.Number & " " & Err.Description
                Err.Clear
              End If
             End If
             On Error GoTo 0
    End Sub
    VBA Noob

+ 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