ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Rename Tab with Textbox on Worksheet (https://www.excelbanter.com/excel-programming/407488-rename-tab-textbox-worksheet.html)

LRay67

Rename Tab with Textbox on Worksheet
 
How would I rename the tab with a Text Box on a worksheet? Not a
userform

I've tried the following doesn't seem to work.

Private Sub TextBox127_LostFocus()
ActiveSheet.Name = Me.Textbox127.value
End Sub



Patrick Molloy[_2_]

Rename Tab with Textbox on Worksheet
 
most people would hit ENTER when they're done ...so use the textbox's KEYDOWN
method to check if its been pressed....


Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal
Shift As Integer)
If KeyCode = 13 Then
If TextBox1.Value < "" Then
On Error Resume Next
ActiveSheet.Name = TextBox1.Value
On Error GoTo 0
End If
End If
End Sub



"LRay67" wrote:

How would I rename the tab with a Text Box on a worksheet? Not a
userform

I've tried the following doesn't seem to work.

Private Sub TextBox127_LostFocus()
ActiveSheet.Name = Me.Textbox127.value
End Sub



LRay67

Rename Tab with Textbox on Worksheet
 
Patrick, thanks for the info.

I am not marco/progrmamer literate, not sure what you are referring to with
the textbox's KEYDOWN method. Can you help?

This is what I have placed on the individual worksheet (code sheet)

Private Sub TextBox127_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 13 Then
If TextBox127.value < "" Then
On Error Resume Next
ActiveSheet.Name = TextBox127.value
On Error GoTo 0
End If
End If
End Sub


"Patrick Molloy" wrote:

most people would hit ENTER when they're done ...so use the textbox's KEYDOWN
method to check if its been pressed....


Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal
Shift As Integer)
If KeyCode = 13 Then
If TextBox1.Value < "" Then
On Error Resume Next
ActiveSheet.Name = TextBox1.Value
On Error GoTo 0
End If
End If
End Sub



"LRay67" wrote:

How would I rename the tab with a Text Box on a worksheet? Not a
userform

I've tried the following doesn't seem to work.

Private Sub TextBox127_LostFocus()
ActiveSheet.Name = Me.Textbox127.value
End Sub



Patrick Molloy[_2_]

Rename Tab with Textbox on Worksheet
 
looks good.

"LRay67" wrote:

Patrick, thanks for the info.

I am not marco/progrmamer literate, not sure what you are referring to with
the textbox's KEYDOWN method. Can you help?

This is what I have placed on the individual worksheet (code sheet)

Private Sub TextBox127_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 13 Then
If TextBox127.value < "" Then
On Error Resume Next
ActiveSheet.Name = TextBox127.value
On Error GoTo 0
End If
End If
End Sub


"Patrick Molloy" wrote:

most people would hit ENTER when they're done ...so use the textbox's KEYDOWN
method to check if its been pressed....


Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal
Shift As Integer)
If KeyCode = 13 Then
If TextBox1.Value < "" Then
On Error Resume Next
ActiveSheet.Name = TextBox1.Value
On Error GoTo 0
End If
End If
End Sub



"LRay67" wrote:

How would I rename the tab with a Text Box on a worksheet? Not a
userform

I've tried the following doesn't seem to work.

Private Sub TextBox127_LostFocus()
ActiveSheet.Name = Me.Textbox127.value
End Sub




All times are GMT +1. The time now is 08:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com