Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Rename Tabs With Code

  1. #1
    Join Date
    20th October 2006
    Location
    somewhere between London, UK and Midwest, USA
    Posts
    31

    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.

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

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    15th August 2005
    Location
    Mechelen, Belgium
    Posts
    6,039

    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 at 20:36.
    Regards,

    Wigi

    Excel MVP 2011, 2012, 2013



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

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

  3. #3
    Join Date
    20th October 2006
    Location
    somewhere between London, UK and Midwest, USA
    Posts
    31

    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?

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    15th August 2005
    Location
    Mechelen, Belgium
    Posts
    6,039

    Re: Rename Tabs Within Vba

    See attached file where it works for me.

    Wigi
    Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.
    Regards,

    Wigi

    Excel MVP 2011, 2012, 2013



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

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

  5. #5
    Join Date
    20th October 2006
    Location
    somewhere between London, UK and Midwest, USA
    Posts
    31

    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?

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    15th August 2005
    Location
    Mechelen, Belgium
    Posts
    6,039

    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 at 18:46.
    Regards,

    Wigi

    Excel MVP 2011, 2012, 2013



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

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

  7. #7
    Join Date
    20th October 2006
    Location
    somewhere between London, UK and Midwest, USA
    Posts
    31

    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.

    Excel Video Tutorials / Excel Dashboards Reports


  8. #8
    Join Date
    20th October 2006
    Location
    somewhere between London, UK and Midwest, USA
    Posts
    31

    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. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.

    Excel Video Tutorials / Excel Dashboards Reports


  9. #9
    Join Date
    15th August 2005
    Location
    Mechelen, Belgium
    Posts
    6,039

    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:

    VB:
    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, 2012, 2013



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

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

  10. #10
    Join Date
    20th October 2006
    Location
    somewhere between London, UK and Midwest, USA
    Posts
    31

    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?

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Rename/Name Sheet Tabs Based on a Cell
    By ilpap75 in forum EXCEL HELP
    Replies: 5
    Last Post: February 24th, 2012, 05:30
  2. Rename Worksheets From Cell Text Without Code
    By Absa in forum EXCEL HELP
    Replies: 2
    Last Post: August 11th, 2007, 00:09
  3. Rename Worksheet Code
    By guerilla in forum EXCEL HELP
    Replies: 7
    Last Post: December 13th, 2006, 20:28
  4. Click button to rename sheet tabs based on range
    By sweather in forum EXCEL HELP
    Replies: 24
    Last Post: August 16th, 2006, 07:35
  5. Rename Excel sheet in VBA code
    By RussScott in forum EXCEL HELP
    Replies: 4
    Last Post: July 21st, 2004, 23:27

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
  •  
porno