close

Hello everyone

I have managed to get a VBA to change the name of a sheet for me which
is now displayed below. The below is thanks to HTHPrivate Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets(quot; Name = Range(quot;K1quot;).Value

End Sub

But the problem now is after it as changed the name from quot;Temp 11quot; to
Range name in cell K1 the above formula now keeps looking for Sheet
name quot;Temp 11quot; everytime I open the sheet. Could someone please help
tell how to tell it to ignor if unable to find the sheet name quot;Temp
11quot;. I am only new at this but I am a very persistant person and plan
on learning as much as I can.

Paul Maynard
Moscow
Russia.--
paulrm906

probably should save as that name...
--
paul
remove nospam for email addy!
quot;paulrm906quot; wrote:

gt;
gt; Hello everyone
gt;
gt; I have managed to get a VBA to change the name of a sheet for me which
gt; is now displayed below. The below is thanks to HTH
gt;
gt;
gt; Private Sub Worksheet_SelectionChange(ByVal Target As Range)
gt; Worksheets(quot; Name = Range(quot;K1quot;).Value
gt;
gt; End Sub
gt;
gt; But the problem now is after it as changed the name from quot;Temp 11quot; to
gt; Range name in cell K1 the above formula now keeps looking for Sheet
gt; name quot;Temp 11quot; everytime I open the sheet. Could someone please help
gt; tell how to tell it to ignor if unable to find the sheet name quot;Temp
gt; 11quot;. I am only new at this but I am a very persistant person and plan
gt; on learning as much as I can.
gt;
gt; Paul Maynard
gt; Moscow
gt; Russia.
gt;
gt;
gt; --
gt; paulrm906
gt;

That code errors for me. What formula are you referring to?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

quot;paulrm906quot; gt; wrote in message
news
gt;
gt; Hello everyone
gt;
gt; I have managed to get a VBA to change the name of a sheet for me which
gt; is now displayed below. The below is thanks to HTH
gt;
gt;
gt; Private Sub Worksheet_SelectionChange(ByVal Target As Range)
gt; Worksheets(quot; Name = Range(quot;K1quot;).Value
gt;
gt; End Sub
gt;
gt; But the problem now is after it as changed the name from quot;Temp 11quot; to
gt; Range name in cell K1 the above formula now keeps looking for Sheet
gt; name quot;Temp 11quot; everytime I open the sheet. Could someone please help
gt; tell how to tell it to ignor if unable to find the sheet name quot;Temp
gt; 11quot;. I am only new at this but I am a very persistant person and plan
gt; on learning as much as I can.
gt;
gt; Paul Maynard
gt; Moscow
gt; Russia.
gt;
gt;
gt; --
gt; paulrm906
Are you trying to rename the same sheet that owns this code?

If yes:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Me.Name = Me.Range(quot;K11quot;).Value
If Err.Number lt;gt; 0 Then
MsgBox quot;Rename failedquot;
Err.Clear
End If
On Error GoTo 0
End Sub

If wanted to rename a different sheet in the workbook, you could use the code
name. That's the name you see in the project explorer.

CodeName WorksheetName
Sheet3 (WhatYouSeeOnTheTab)

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Sheet3.Name = Me.Range(quot;K11quot;).Value
If Err.Number lt;gt; 0 Then
MsgBox quot;Rename failedquot;
Err.Clear
End If
On Error GoTo 0
End Sub

I used the worksheet_change event. You were trying to rename the sheet each
time you changed selection. I didn't understand that.

paulrm906 wrote:
gt;
gt; Hello everyone
gt;
gt; I have managed to get a VBA to change the name of a sheet for me which
gt; is now displayed below. The below is thanks to HTH
gt;
gt; Private Sub Worksheet_SelectionChange(ByVal Target As Range)
gt; Worksheets(quot; Name = Range(quot;K1quot;).Value
gt;
gt; End Sub
gt;
gt; But the problem now is after it as changed the name from quot;Temp 11quot; to
gt; Range name in cell K1 the above formula now keeps looking for Sheet
gt; name quot;Temp 11quot; everytime I open the sheet. Could someone please help
gt; tell how to tell it to ignor if unable to find the sheet name quot;Temp
gt; 11quot;. I am only new at this but I am a very persistant person and plan
gt; on learning as much as I can.
gt;
gt; Paul Maynard
gt; Moscow
gt; Russia.
gt;
gt; --
gt; paulrm906

--

Dave Peterson

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()