Search code examples
vbatable-rename

Need a VBA code. rename sheets from list


Need a VBA code. rename sheets from list

I have a list of names in sheet 2 cell w3 thru w22. I need to name sheets/tabs 3 thur 22 from the the list of names. The names change. and if no name in w3 thru w22. I want the tabs to be numbered 1 thru 20 Any Ideas?


Solution

  •     Dim MyCell As Range, MyRange As Range, Dim i As Integer 
    
        Set MyRange = Sheets("Summary").Range("w3") 
        Set MyRange = Range(MyRange, MyRange.End(xlDown)) 
    
        For Each MyCell In MyRange 
        If MyCell.Value IS NULL
        Sheets(Sheets.Count + 3).Name = i
        Sheets(Sheets.Count + 3).Name = MyCell.Value ' renames the new worksheet 
        Next MyCell 
    

    Or something like this maybe, I didn't test it since you didn't give us anything to go off of or make any effort to solve it yourself. http://en.kioskea.net/faq/27361-excel-a-macro-to-create-and-name-worksheets-based-on-a-list Kudos to this website for giving me a basis to go off of.