Renaming Worksheet

N

Noepie

Hello all,

I have the following problem which I'd like to solve with a macro. Is it
possible to run a macro that renames the worksheet with the text I put in
this worksheet in cell B1, e.g.? I hope there is a solution.

Thanx for your help.

Kind regards,

Noepie
 
G

Gary Keramidas

here are 2 examples, one using activesheet and one using the index number, which
is the first sheet in this case:

Sub rename_sheet()
With Worksheets(1)
..Name = .Range("B1").Value
End With
End Sub

Sub rename_sheet()
With ActiveSheet
..Name = .Range("B1").Value
End With
End Sub
 
P

Per Jessen

Hello Noepie

This is an event code, so it has to be copied into the codesheet for the
desired sheet.
Right click on the desired sheet tab and select "View Code". Paste the code
below.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("B1") Then
If Target.Value <> "" Then
ActiveSheet.Name = Target.Value
End If
End If
End Sub

Regards,
Per
 
N

Noepie

Dear Per / Gary,

Both ways give the desired result, so thanx for helping me out.

Kind regards,

Noepie
 

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