ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to name sheet tabs (https://www.excelbanter.com/excel-discussion-misc-queries/183201-macro-name-sheet-tabs.html)

Bill_S

Macro to name sheet tabs
 
I need a macro that will automatically name the sheet tab the date that I
enter in cell E4 on my worksheet. I tried the following macro:

Sub Worksheet_Change ()
ws.Name = ws.Range("E4").Value
End Sub

It automatically runs when I enter a new date in cell E4, which is good.
What isn't good is that it gives the following error message:

"Compile error: Procedure declaration does not match description of event or
procedure having the same name."

How can I get this macro to work?

Gary''s Student

Macro to name sheet tabs
 
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("E4")
Set t = Target
If Intersect(t, r) Is Nothing Then Exit Sub
ActiveSheet.Name = r.Value
End Sub

In the worksheet code area
--
Gary''s Student - gsnu200778


"Bill_S" wrote:

I need a macro that will automatically name the sheet tab the date that I
enter in cell E4 on my worksheet. I tried the following macro:

Sub Worksheet_Change ()
ws.Name = ws.Range("E4").Value
End Sub

It automatically runs when I enter a new date in cell E4, which is good.
What isn't good is that it gives the following error message:

"Compile error: Procedure declaration does not match description of event or
procedure having the same name."

How can I get this macro to work?


Don Guillett

Macro to name sheet tabs
 
Private Sub Worksheet_Change(ByVal Target As Range)
if target.address<"$E$4" then exit sub
activesheet.name=target
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Bill_S" wrote in message
...
I need a macro that will automatically name the sheet tab the date that I
enter in cell E4 on my worksheet. I tried the following macro:

Sub Worksheet_Change ()
ws.Name = ws.Range("E4").Value
End Sub

It automatically runs when I enter a new date in cell E4, which is good.
What isn't good is that it gives the following error message:

"Compile error: Procedure declaration does not match description of event
or
procedure having the same name."

How can I get this macro to work?



Bill_S

Macro to name sheet tabs
 
Excellent! Thank you!
-Bill

"Gary''s Student" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("E4")
Set t = Target
If Intersect(t, r) Is Nothing Then Exit Sub
ActiveSheet.Name = r.Value
End Sub

In the worksheet code area
--
Gary''s Student - gsnu200778


"Bill_S" wrote:

I need a macro that will automatically name the sheet tab the date that I
enter in cell E4 on my worksheet. I tried the following macro:

Sub Worksheet_Change ()
ws.Name = ws.Range("E4").Value
End Sub

It automatically runs when I enter a new date in cell E4, which is good.
What isn't good is that it gives the following error message:

"Compile error: Procedure declaration does not match description of event or
procedure having the same name."

How can I get this macro to work?


Bill_S

Macro to name sheet tabs
 
Don- thx for the streamlined version too!
-Bill

"Don Guillett" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.address<"$E$4" then exit sub
activesheet.name=target
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Bill_S" wrote in message
...
I need a macro that will automatically name the sheet tab the date that I
enter in cell E4 on my worksheet. I tried the following macro:

Sub Worksheet_Change ()
ws.Name = ws.Range("E4").Value
End Sub

It automatically runs when I enter a new date in cell E4, which is good.
What isn't good is that it gives the following error message:

"Compile error: Procedure declaration does not match description of event
or
procedure having the same name."

How can I get this macro to work?





All times are GMT +1. The time now is 02:18 AM.

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