Results 1 to 4 of 4

renaming tabs macro

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-12-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    448

    renaming tabs macro

    Hell. I have the following code. The purpose is to take column A code number, the corresponding name (1, Alice, for example) and then rename all the sheets to that combined name. There are ten sheets (1-10) that start at worksheet four (after a couple of instruction sheets). An error comes up and says "can't assign to array" What does this mean?

    Also, this is just an exercise. I know there is a better way to do this. I was instructed to use one for loop, and at least one array variable, which I believe that I've done. In addition to fixing my code can someone suggest more efficient ways of the doing the renaming. The Codes are in column 1, the names are in column 2, in the "Data" tab, which is 3rd tab in the workbook. The fourth tab starts the sheets (1-10) Please help!!!!


    Sub RenamingTabsPart4()
    
    Dim IdName(1 To 10) As String
    IdName = "1 - Alice"
    IdName = "2 - Bob"
    IdName = "3 - Jim"
    IdName = "5 - Sally"
    IdName = "10 - Wally"
    IdName = "8 - Peter"
    IdName = "9 - James"
    IdName = "6 - Sara"
    IdName = "7 - Scott"
    IdName = "2 - Carlos"
    
    For i = 4 To 10
    
    Dim IdName(1 To 10)
    Sheet(i).Select
    ActiveSheet.Name = IdName(i - 3)
    
    Next i
    
    End Sub
    Last edited by JBeaucaire; 06-17-2013 at 10:23 AM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

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