Reputation: 1
I have about 50 workbooks each with two tabs. I want to rename the first worksheet with the same name that of the workbook name. I know how to to this when there is only one worksheet tab in the workbook. But It does not work with multiple tabs. How can I use VBA to dynamically rename worksheets that is same name as workbook name?
Upvotes: 0
Views: 709
Reputation: 612
This will rename a worksheet to have the same name as the workbook it is in:
Worksheets(1).Name = ActiveWorkbook.Name
If there are several workbooks and you want to rename the first worksheet in each automatically, you could build a loop around this statement that opens each workbook and then runs the line of code above.
Upvotes: 0