+ Reply to Thread
Results 1 to 4 of 4

Tab-naming macro only works once :-(

  1. #1
    Stilla
    Guest

    Tab-naming macro only works once :-(

    Hi.. thanks to you guys, I learned to name tabs with a macro. I changed some
    information on some worksheets, and tried to run the macro again to adjust
    tab names... but nothing happened. What's wrong?

    This is the macro I'm using (aa3 is the cell in each sheet that contains the
    name):

    Sub TABNAMING()
    Dim i As Integer
    On Error Resume Next
    For i = 1 To Sheets.Count
    Sheets(i).Name = Sheets(i).Range("aa3").Value
    Next i
    On Error GoTo 0
    End Sub


  2. #2
    Gary''s Student
    Guest

    RE: Tab-naming macro only works once :-(

    When using VBA to re-name sheets a common mishap is that the code tries to
    assign a name that is already taken by another sheet the first time around.


    --
    Gary's Student


    "Stilla" wrote:

    > Hi.. thanks to you guys, I learned to name tabs with a macro. I changed some
    > information on some worksheets, and tried to run the macro again to adjust
    > tab names... but nothing happened. What's wrong?
    >
    > This is the macro I'm using (aa3 is the cell in each sheet that contains the
    > name):
    >
    > Sub TABNAMING()
    > Dim i As Integer
    > On Error Resume Next
    > For i = 1 To Sheets.Count
    > Sheets(i).Name = Sheets(i).Range("aa3").Value
    > Next i
    > On Error GoTo 0
    > End Sub
    >


  3. #3
    christine.bastel@web.de
    Guest

    Re: Tab-naming macro only works once :-(

    Try this:


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Address = "$A$1" Then
    If Target.Value <> "" Then
    Me.Name = Target.Value
    End If
    End If
    End Sub

    Where "$A$1" needs to be changed to the cell that contains the tabname.
    You will find, theat when you refresh, the names do not refresh
    immediately. However, select A1 in groupmode, click CTRL+C and CTRL+V
    - given that every sheet has an individual name, you should be finr


  4. #4
    Stilla
    Guest

    RE: Tab-naming macro only works once :-(

    THANK YOU EVERYBODY!

    "Stilla" wrote:

    > Hi.. thanks to you guys, I learned to name tabs with a macro. I changed some
    > information on some worksheets, and tried to run the macro again to adjust
    > tab names... but nothing happened. What's wrong?
    >
    > This is the macro I'm using (aa3 is the cell in each sheet that contains the
    > name):
    >
    > Sub TABNAMING()
    > Dim i As Integer
    > On Error Resume Next
    > For i = 1 To Sheets.Count
    > Sheets(i).Name = Sheets(i).Range("aa3").Value
    > Next i
    > On Error GoTo 0
    > End Sub
    >


+ 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