Rename 500 Sheets based on Modified Cell Value on each sheet

  • I recieve a workbook each day with approx 500 tabs of call data and I would like to relabel all the tabs with the user names. The user names are in a merged range "A7:M7". I'm having difficulty getting the following script to rename the sheets. Currently the values in "A7:M7" look like "User: ADAM ENGEMANN-558".


    I am trying to delete each occurrence of "User: " while naming the sheets as well as removing the merged range before doing so that the names are in A7 only. The sheet names should look like "ADAM ENGEMANN-558", or, ideally just "ADAM ENGEMANN". For some reason my code will not modify the cells and I can't figure out why. It's really driving me crazy. Any help much appreciated! (see attached example)



    This works if I manually unmerge the cells before running and remove the ":".


    This his how I modified it but it doesn't work on the supplied sheets. Please note that if I manually insert some blank sheets into my workbook and merge the cells etc it does work. There seems to be something odd going on with the sheets they are giving me. (they aren't protected)



    forum.ozgrid.com/index.php?attachment/55428/

  • Re: Rename 500 Sheets based on Modified Cell Value on each sheet


    Code
    Sub RenameSheets2()
        Dim ws As Worksheet
        For Each ws In ThisWorkbook.Worksheets
            If ws.Range("A7").Value <> "" Then
                sname = Right(ws.Range("A7").Value, Len(ws.Range("A7").Value) - 6)
                ws.Name = sname
            End If
        Next ws
         
    End Sub
  • Re: Rename 500 Sheets based on Modified Cell Value on each sheet


    Or:


    Code
    Sub RenameSheets2()
    
    
        For Each ws In ThisWorkbook.Sheets
           ws.Name = Trim(Mid(ws.Range("A7") & Space(6), 7))
        Next
         
    End Sub

    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) --

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!