Announcement

Collapse
No announcement yet.

Rename Tabs With Code

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rename Tabs With Code

    I am pulling my hair out in frustration with this right now. I have a .csv file that I am attempting to run a macro on. I will need to move between tabs, and want to rename a tab to remove the date as it is not consistent in format. I have tried numerous ways, and I don't get an error message, but the tab is not renamed either. Code I have tried is below.

    Code:
     ActiveSheet.Name = "ReportName"
    Code:
     Dim WsName As String
    
    With ActiveSheet
        WsName = .Name
    End With
    
    Sheets(WsName).Name = "ReportName"
    Thanks for the help.

  • #2
    Re: Rename Tabs Within Vba

    Perhaps ReportName IS already the activesheet?


    Related Pages: Add & Name Sheets | Add Worksheets in Month Order | Add Worksheets in Numeric Order
    Last edited by Dave Hawley; January 10th, 2007, 21:36.
    Regards,

    Wigi

    Excel MVP 2011-2014

    For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

    -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

    Comment


    • #3
      Re: Rename Tabs Within Vba

      The tab name is ReportName 9.1.07. I want to remove the date as the formating is very inconsisten, sometimes using . other times using -.

      Is this possible to change?

      Comment


      • #4
        Re: Rename Tabs Within Vba

        See attached file where it works for me.

        Wigi
        Attached Files
        Regards,

        Wigi

        Excel MVP 2011-2014

        For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

        -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

        Comment


        • #5
          Re: Rename Tabs Within Vba

          this is why I am confused, it has worked for me in the past just fine.

          Would the fact that it is a .csv file impact that?

          Comment


          • #6
            Re: Rename Tabs Within Vba

            Can you attach a small part of it here for us to to play around with it?
            Last edited by Wigi; January 10th, 2007, 19:46.
            Regards,

            Wigi

            Excel MVP 2011-2014

            For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

            -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

            Comment


            • #7
              Re: Rename Tabs Within Vba

              I have also tried renaming it something completely unrelated which also does not work. But if I right click and rename on the tab it works fine.

              Comment


              • #8
                Re: Rename Tabs Within Vba

                Sorry, didn't notice the new reply before I posted the last one.

                And in creating the sample data I figured out that the tab is named by what the worksheet is named. Is there a way to turn this off, or override it?

                Sample is attached
                Attached Files

                Comment


                • #9
                  Re: Rename Tabs Within Vba

                  Hi

                  Don't know what is going on here. I open your file, go to VBA editor alt-f11, then do Insert > Module, and type this:

                  Code:
                  Sub renamesheet()
                      Sheets("tab name example").Name = "Wigi"
                  End Sub
                  I run the code and it does the renaming.

                  Try this also.

                  Wigi
                  Regards,

                  Wigi

                  Excel MVP 2011-2014

                  For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

                  -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

                  Comment


                  • #10
                    Re: Rename Tabs Within Vba

                    It worked for me also, but I can't upload the .csv, so had to change it to .xls. How much of a difference would this make?

                    The other issue is that the tab has the date in it, so is there another way I could do it with just ActiveSheet since the date format changes?

                    Comment


                    • #11
                      Re: Rename Tabs Within Vba

                      Zip your CSV file first, then upload resulting file.

                      Code:
                      ActiveSheet.Name = "ReportName"
                      should work.
                      Regards,

                      Wigi

                      Excel MVP 2011-2014

                      For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes

                      -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

                      Comment

                      Working...
                      X