ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   What is wrong? (https://www.excelbanter.com/excel-discussion-misc-queries/219190-what-wrong.html)

robert morris

What is wrong?
 


I use this VBA Code to change the Tab name at the same time as I enter a
name in Cell B2. Why doesn't it work? I use the same code in another
Workbook and it works.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$B$2" Then Sh.Name = Target.Value
End Sub



Any ideas?

Bob M.


robert morris

What is wrong?
 

Duh??

I feel "blonde".

Thanks Max

Bob M.



"Max" wrote:

Works fine in testing here,
provided B2 contains a valid sheetname (w/o prohibited chars)

In VBE, did you install it in "ThisWorkbook"?
It's meant to be placed there.
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---
"robert morris" wrote:
I use this VBA Code to change the Tab name at the same time as I enter a
name in Cell B2. Why doesn't it work? I use the same code in another
Workbook and it works.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$B$2" Then Sh.Name = Target.Value
End Sub



Max

What is wrong?
 
No prob, Bob. Happens to me, too.
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:23,000 Files:370 Subscribers:66
xdemechanik
---
"robert morris" wrote in message
...

Duh??

I feel "blonde".

Thanks Max

Bob M.




Per Jessen

What is wrong?
 
Hi Bob

My guess is that you haven't put the macro into the right place.

As it is a workbook event code it has to be in the code sheet for
ThisWorkbook.

Hopes this helps.

---
Per

"robert morris" skrev i meddelelsen
...


I use this VBA Code to change the Tab name at the same time as I enter a
name in Cell B2. Why doesn't it work? I use the same code in another
Workbook and it works.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
If Target.Address = "$B$2" Then Sh.Name = Target.Value
End Sub



Any ideas?

Bob M.



robert morris

What is wrong?
 
Per,

You and Max were both correct! I did not have the code in ThisWorkbook.
Sometimes "the trees and the forest" comes to play.

Many Thanks

Bob



"Per Jessen" wrote:

Hi Bob

My guess is that you haven't put the macro into the right place.

As it is a workbook event code it has to be in the code sheet for
ThisWorkbook.

Hopes this helps.

---
Per

"robert morris" skrev i meddelelsen
...


I use this VBA Code to change the Tab name at the same time as I enter a
name in Cell B2. Why doesn't it work? I use the same code in another
Workbook and it works.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
If Target.Address = "$B$2" Then Sh.Name = Target.Value
End Sub



Any ideas?

Bob M.




Per Jessen[_2_]

What is wrong?
 
Bob,

I'm glad that you found your way through the forrest :-)

Regards,
Per

On 6 Feb., 02:54, robert morris
wrote:
Per,

You and Max were both correct! *I did not have the code in ThisWorkbook.. *
Sometimes "the trees and the forest" comes to play.

Many Thanks

Bob



"Per Jessen" wrote:
Hi Bob


My guess is that you haven't put the *macro into the right place.


As it is a workbook event code it has to be in the code sheet for
ThisWorkbook.


Hopes this helps.


---
Per


"robert morris" skrev i meddelelsen
...


I use this VBA Code to change the Tab name at the same time as I enter a
name in Cell B2. *Why doesn't it work? *I use the same code in another
Workbook and it works.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
If Target.Address = "$B$2" Then Sh.Name = Target.Value
End Sub


Any ideas?


Bob M.- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -




All times are GMT +1. The time now is 08:12 AM.

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