Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default naming worksheets


I want to match the name of a worksheet tab with the header of a form.
In other words, if I type the name of the form in a header (a
cell), the worksheet tab would change the name to match the header
name.

Here's what I'm using but it's not working:

Private Sub workbook_SheetChange(ByVal sh As Object, ByVal target As
Range)
If target.Address = "$d$1" Then sh.Name = target
End Sub

Can anyone tell me what I'm doing wrong? THANKS!


--
jerrystan
------------------------------------------------------------------------
jerrystan's Profile: http://www.excelforum.com/member.php...o&userid=28573
View this thread: http://www.excelforum.com/showthread...hreadid=494190

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default naming worksheets

Has to be upper-case

Private Sub workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
If Target.Address = "$D$1" Then sh.Name = Target.Value
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"jerrystan" wrote
in message ...

I want to match the name of a worksheet tab with the header of a form.
In other words, if I type the name of the form in a header (a
cell), the worksheet tab would change the name to match the header
name.

Here's what I'm using but it's not working:

Private Sub workbook_SheetChange(ByVal sh As Object, ByVal target As
Range)
If target.Address = "$d$1" Then sh.Name = target
End Sub

Can anyone tell me what I'm doing wrong? THANKS!


--
jerrystan
------------------------------------------------------------------------
jerrystan's Profile:

http://www.excelforum.com/member.php...o&userid=28573
View this thread: http://www.excelforum.com/showthread...hreadid=494190



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default naming worksheets

Try:

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

Regards,
Greg

"jerrystan" wrote:


I want to match the name of a worksheet tab with the header of a form.
In other words, if I type the name of the form in a header (a
cell), the worksheet tab would change the name to match the header
name.

Here's what I'm using but it's not working:

Private Sub workbook_SheetChange(ByVal sh As Object, ByVal target As
Range)
If target.Address = "$d$1" Then sh.Name = target
End Sub

Can anyone tell me what I'm doing wrong? THANKS!


--
jerrystan
------------------------------------------------------------------------
jerrystan's Profile: http://www.excelforum.com/member.php...o&userid=28573
View this thread: http://www.excelforum.com/showthread...hreadid=494190


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default naming worksheets


Thanks guys, but I'm still getting an error. Could my other macros in
this file be affecting it??


--
jerrystan
------------------------------------------------------------------------
jerrystan's Profile: http://www.excelforum.com/member.php...o&userid=28573
View this thread: http://www.excelforum.com/showthread...hreadid=494190

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default naming worksheets

Did you put the code in the ThisWorkbook code module?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"jerrystan" wrote
in message ...

Thanks guys, but I'm still getting an error. Could my other macros in
this file be affecting it??


--
jerrystan
------------------------------------------------------------------------
jerrystan's Profile:

http://www.excelforum.com/member.php...o&userid=28573
View this thread: http://www.excelforum.com/showthread...hreadid=494190





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default naming worksheets

Your code will error out if there is already a sheet by that name or if you
try to use name the sheet "History". You can add this procedure to check if a
sheet by that name already exists...

Public Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function

Additionally the code will not catch if anything is pasted into the cell.
The only code that should affect this is application.enableevents = ?? which
could effectively turn it off, but it will not cause an error.
--
HTH...

Jim Thomlinson


"jerrystan" wrote:


Thanks guys, but I'm still getting an error. Could my other macros in
this file be affecting it??


--
jerrystan
------------------------------------------------------------------------
jerrystan's Profile: http://www.excelforum.com/member.php...o&userid=28573
View this thread: http://www.excelforum.com/showthread...hreadid=494190


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default naming worksheets


I set up another workbook to test this and it works in there. It mus
have something to do with my existing code. I checked for duplicat
names and the "history" name and its all good. I'll keep messing wit
it. Thanks for your help

--
jerrysta
-----------------------------------------------------------------------
jerrystan's Profile: http://www.excelforum.com/member.php...fo&userid=2857
View this thread: http://www.excelforum.com/showthread.php?threadid=49419

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming Worksheets LIAMT Excel Worksheet Functions 1 August 21st 05 02:41 PM
Naming Worksheets Chaz Excel Programming 1 July 25th 05 03:29 PM
naming worksheets Shooter Excel Worksheet Functions 1 December 3rd 04 04:09 PM
Worksheets Add & Naming Kevin H. Stecyk[_2_] Excel Programming 4 August 20th 04 05:19 PM
Naming Worksheets in VBE Don Guillett[_4_] Excel Programming 0 July 18th 03 08:17 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"