Worksheet Names

V

veggies27

Is it possible to name worksheets based on a formula?

I want sheet1 to be renamed to be whatever is in sheet1!A1 for instance.
 
M

Mike H

Hi,

Right click the sheet tab, view code and paste this in

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
ActiveSheet.Name = Range("A1").Value
End Sub

Mike
 
D

Dave Peterson

Since it's based on a formula, then maybe using _calculate would be a better
event to use:

Option Explicit
Private Sub Worksheet_Calculate()
On Error Resume Next
Me.Name = Me.Range("a1").Value
If Err.Number <> 0 Then
Beep
MsgBox "Invalid name in A1!"
Err.Clear
End If
 

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