rename multiple worksheets based on a list

abcx1975

New Member
Joined
Mar 22, 2018
Messages
2
I have a workbook with multiple tabs/worksheets. I need to rename the tabs based on a list in one of the tab. The list has 2 columns - A and B. There are names of tabs in column B but they needs to be renamed by their corresponding cells in column A. e.g.
column A Column B
abcd rtyu
htyu gui
usa rss
So the macro should search the tab names and if any of the tab is named as in column B (say rss) then it should be renamed to its corresponding entry in column A (i.e. usa in this case). Any guidance will be much appreciated.+


EDIT: The tab name with the list is fixed - "Summary"

 
Last edited by a moderator:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Welcome to the Board!

Try this:
Code:
Sub MyRenameSheets()

    Dim lrow As Long
    Dim r As Long
    Dim prevNm As String
    Dim newNm As String
    
    Application.ScreenUpdating = False
    
'   Find last row in column A on Summary sheet with data
    lrow = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row
    
    On Error Resume Next
'   Loop through all rows on Summary sheet starting on row 2
    For r = 2 To lrow
'       Capture values
        prevNm = Sheets("Summary").Cells(r, "A")
        newNm = Sheets("Summary").Cells(r, "B")
'       Rename sheets
        Sheets(prevNm).Name = newNm
    Next r
    On Error GoTo 0
    
    Application.ScreenUpdating = True
        
End Sub
 
Upvote 0
Is it possible to have the macro reference a table instead? So for example, if on the "Summary" tab there's a table with multiple columns and column "A" in the example above is in the 1st column of the table and column "B" in the example above is in the 4th column of the table?
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,394
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top