ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Rename a Worksheet on Input of Value in Cell (https://www.excelbanter.com/excel-worksheet-functions/106916-rename-worksheet-input-value-cell.html)

John

Rename a Worksheet on Input of Value in Cell
 
I have the following code with the relevant sheet code. What I'm ytring to
achieve is when a value is entered in C5 then the Worksheet is renamed as
what is entered in C5. Only problem is that it doesn't do anything for me.
What am I doing wrong?

Thanks



Private Sub Worksheet_Change(ByVal Target As Range)
Dim Shouldbe As String
With Target
If .Address = "$C$5" Then
If .HasFormula = False Then
Shouldbe = StrConv(.Value, vbProperCase)
If .Value < Shouldbe Then _
.Value = Shouldbe
End If
End If
End With
End Sub



John

Rename a Worksheet on Input of Value in Cell
 
Just closed the file and opened it up and now whatever I enter in C5 changes
the name of the sheet as desired. Why did it do that when I closed and
reopened?



"John" wrote in message
...
I have the following code with the relevant sheet code. What I'm ytring to
achieve is when a value is entered in C5 then the Worksheet is renamed as
what is entered in C5. Only problem is that it doesn't do anything for me.
What am I doing wrong?

Thanks



Private Sub Worksheet_Change(ByVal Target As Range)
Dim Shouldbe As String
With Target
If .Address = "$C$5" Then
If .HasFormula = False Then
Shouldbe = StrConv(.Value, vbProperCase)
If .Value < Shouldbe Then _
.Value = Shouldbe
End If
End If
End With
End Sub





All times are GMT +1. The time now is 04:31 AM.

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