Renaming worksheet on the basis of workbook name

A

andreashermle

Dear Experts:

I got an excel file named Chapter1.xls

The fourth worksheet of this file should be renamed via VBA as
follows:

NoMatch_1

I would like to use this code (snippet) for the renaming of other
worksheets as well, such as

File name: Chapter2.xls: renaming of worksheet 4 to 'NoMatch_2'
File name: Chapter3.xls: renaming of worksheet 4 to 'NoMatch_3'

That is the number at the end of the relevant excel file name is to be
placed at the end of the fourth worksheet name. (NoMatch_relevant
number)

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
J

James Ravenswood

Dear Experts:

I got an excel file named Chapter1.xls

The fourth worksheet of this file should be renamed via VBA as
follows:

NoMatch_1

I would like to use this code (snippet) for the renaming of other
worksheets as well, such as

File name: Chapter2.xls: renaming of worksheet 4 to 'NoMatch_2'
File name: Chapter3.xls: renaming of worksheet 4 to 'NoMatch_3'

That is the number at the end of the relevant excel file name is to be
placed at the end of the fourth worksheet name. (NoMatch_relevant
number)

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

How about:

Sub ReNameSheet()
numberr = "_" & Right(Split(ActiveWorkbook.Name, ".")(0), 1)
Sheets(4).Name = Sheets(4).Name & numberr
End Sub
 
A

andreashermle

How about:

Sub ReNameSheet()
numberr = "_" & Right(Split(ActiveWorkbook.Name, ".")(0), 1)
Sheets(4).Name = Sheets(4).Name & numberr
End Sub- Hide quoted text -

- Show quoted text -

Hi James,

another praise. Works just fine, Thank you very much for your great
support.

Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top