Leena Ghoshal
Leena Ghoshal

Reputation: 1

RENAME Excel worksheets dynamiccaly using VBA

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

Answers (1)

one angry researcher
one angry researcher

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

Related Questions