+ Reply to Thread
Results 1 to 8 of 8

Rename Worksheet Tabs to Text Contents in Cell G30

  1. #1
    Registered User
    Join Date
    05-18-2011
    Location
    Waverly, Iowa
    MS-Off Ver
    Excel 2003
    Posts
    4

    Rename Worksheet Tabs to Text Contents in Cell G30

    I'm trying to rename several tabs in a workbook to the text in cell G30. This code does not work:

    Sub RenameTabsToNames()

    For i = 1 To Sheets.Count
    If Worksheets(i).Range("G30").Value <> "" Then Sheets(i).Name = Worksheets(i).Range("G30").Value Else: Sheets(i).Name = "RENAME MANUALLY"
    Next
    End Sub

    This part is highlighted when the debugger runs:
    Sheets(i).Name = Worksheets(i).Range("G30").Value Else

    Thank you for any help!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,228

    Re: Rename Worksheet Tabs to Text Contents in Cell G30

    Hi Meridith and welcome to the forum,
    What happens if you change the line to:
    Please Login or Register  to view this content.
    I think you will get an error if you try to name two worksheets the same name also.

    If this doesn't help, let us know.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    05-18-2011
    Location
    Waverly, Iowa
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Rename Worksheet Tabs to Text Contents in Cell G30

    Thanks... but I received a similar error on the same section of code. The names in cell G30 all are unique.

    Any other ideas? The entire code may be completely off.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,228

    Re: Rename Worksheet Tabs to Text Contents in Cell G30

    I'd be looking for stuff in G30 that isn't allowed in sheet names.

    Do some by hand. For example, can you use a space or plus or minus in a sheet name? Are there "funny" characters in the strings in G30? Are you trying to do this in your code?

    When the code breaks try a debug.print (to the immediate window) what you are trying to rename the sheet to. See why this is breaking it.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Rename Worksheet Tabs to Text Contents in Cell G30

    Meredith,

    Give this a try:
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

  6. #6
    Registered User
    Join Date
    05-18-2011
    Location
    Waverly, Iowa
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Rename Worksheet Tabs to Text Contents in Cell G30

    Running the new code, the error says:

    Run-time error '1004':

    Method 'Name' of object'_Worksheet failed

    Highlighted was this:
    wsA.Name = wsA.[G30].Value

    Thank you for the help so far.

    PS The Contents in Cell G30 are again all unique and normal character words.

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Rename Worksheet Tabs to Text Contents in Cell G30

    Meredith,

    The code runs with no errors for me. Are you able to upload a sample workbook that is experiencing the problem so I can see what's going on?

    ~tigeravatar

  8. #8
    Registered User
    Join Date
    05-18-2011
    Location
    Waverly, Iowa
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Rename Worksheet Tabs to Text Contents in Cell G30

    Thanks for the code! I got it to work... it was a problem with some of the sheets being locked first.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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