Is it Possible

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was woundering if I could have the name of the sheet = a cell # on the sheet
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Mike said:
I was woundering if I could have the name of the sheet = a cell # on the
sheet
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Mike said:
I was woundering if I could have the name of the sheet = a cell # on the
sheet
 
Mike,

You can use an event: this code will change the sheet name to that entered into cell A1. Copy the
code, right-click the sheet tab, select "View Code" and paste into the window that appears.

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
On Error Resume Next
Target.Parent.Name = Target.Value
End Sub
 
Mike,

You can use an event: this code will change the sheet name to that entered into cell A1. Copy the
code, right-click the sheet tab, select "View Code" and paste into the window that appears.

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
On Error Resume Next
Target.Parent.Name = Target.Value
End Sub
 
Not working what am i doing wrong

Bob Phillips said:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)


sheet
 
Not working what am i doing wrong

Bob Phillips said:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)


sheet
 
Not working what am i doing wrong

Bernie Deitrick said:
Mike,

You can use an event: this code will change the sheet name to that entered into cell A1. Copy the
code, right-click the sheet tab, select "View Code" and paste into the window that appears.

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
On Error Resume Next
Target.Parent.Name = Target.Value
End Sub
 
Not working what am i doing wrong

Bernie Deitrick said:
Mike,

You can use an event: this code will change the sheet name to that entered into cell A1. Copy the
code, right-click the sheet tab, select "View Code" and paste into the window that appears.

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
On Error Resume Next
Target.Parent.Name = Target.Value
End Sub
 
Did you add it to the sheet code module? If so, change A1 and watch it
change.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Did you add it to the sheet code module? If so, change A1 and watch it
change.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Could i e-mail you the sheet

Bob Phillips said:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)


sheet
 
Could i e-mail you the sheet

Bob Phillips said:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)


sheet
 
Probably unorthodox, but this seems to work for Cell A1.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = "" Then End
ActiveSheet.Name = Range("A1").Value
End Sub
 
Probably unorthodox, but this seems to work for Cell A1.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = "" Then End
ActiveSheet.Name = Range("A1").Value
End Sub
 
Sure.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Sure.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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

Back
Top