Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Dynamic Worksheet Names

I inserted the following code for each worksheet tab to dynamically change
the sheet name to match the value in the designated target cell in that
worksheet:

Private Sub Worksheet_Activate()
ActiveSheet.Name = Range("C7").Value
End Sub


It works OK with one quirk that I don't know how to fix.

When I change the value in the target worksheet cell (C7), the worksheet tab
name does not change until I click on another worksheet tab, then click back
on the worksheet tab I just changed.

How do I make the tab name change as soon as the target cell is updated ?

Thanks !!!
--
HOOS77
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Dynamic Worksheet Names

It's because your using the activate event which only runs when the sheet is
(well) activated, Try this instead

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Name = Range("C7").Value

End Sub


Mike

"HOOS77" wrote:

I inserted the following code for each worksheet tab to dynamically change
the sheet name to match the value in the designated target cell in that
worksheet:

Private Sub Worksheet_Activate()
ActiveSheet.Name = Range("C7").Value
End Sub


It works OK with one quirk that I don't know how to fix.

When I change the value in the target worksheet cell (C7), the worksheet tab
name does not change until I click on another worksheet tab, then click back
on the worksheet tab I just changed.

How do I make the tab name change as soon as the target cell is updated ?

Thanks !!!
--
HOOS77

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Dynamic Worksheet Names

Mike .....

Worked like a charm ! I'm a novice at code writing to say the least. Thank
you so much not only for the help, but for such a prompt reply.

Regards ...
--
HOOS77


"HOOS77" wrote:

I inserted the following code for each worksheet tab to dynamically change
the sheet name to match the value in the designated target cell in that
worksheet:

Private Sub Worksheet_Activate()
ActiveSheet.Name = Range("C7").Value
End Sub


It works OK with one quirk that I don't know how to fix.

When I change the value in the target worksheet cell (C7), the worksheet tab
name does not change until I click on another worksheet tab, then click back
on the worksheet tab I just changed.

How do I make the tab name change as soon as the target cell is updated ?

Thanks !!!
--
HOOS77

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Dynamic Worksheet Names

Try this

Private Sub Worksheet_Activate()
Dim WS As Worksheet
Dim aWS As Worksheet
Dim myWS As Worksheet

Set aWS = ActiveSheet
Set myWS = Nothing

For Each WS In ActiveWorkbook.Worksheets
If WS.Name = aWS.Range("C7") Then
Set myWS = WS
End If
Next WS

If myWS Is Nothing Then
aWS.Name = aWS.Range("C7").Value
Else
MsgBox ("There is already a worksheet with the name " &
aWS.Range("C7").Value)
End If

End Sub

HTH,
Barb Reinhardt



"HOOS77" wrote:

I inserted the following code for each worksheet tab to dynamically change
the sheet name to match the value in the designated target cell in that
worksheet:

Private Sub Worksheet_Activate()
ActiveSheet.Name = Range("C7").Value
End Sub


It works OK with one quirk that I don't know how to fix.

When I change the value in the target worksheet cell (C7), the worksheet tab
name does not change until I click on another worksheet tab, then click back
on the worksheet tab I just changed.

How do I make the tab name change as soon as the target cell is updated ?

Thanks !!!
--
HOOS77

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
dynamic XY chart names [email protected] Excel Discussion (Misc queries) 0 February 9th 07 04:10 PM
How to make worksheet names dynamic? Neil Mitchell-Goodson Excel Worksheet Functions 6 July 18th 06 01:26 PM
Dynamic Worksheet Names Łukasz Czech Links and Linking in Excel 1 August 15th 05 09:41 PM
formula to set up dynamic range in names Jeff Excel Worksheet Functions 0 February 23rd 05 03:45 PM
Dynamic Worksheet Names JClub Excel Worksheet Functions 1 January 10th 05 08:55 PM


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

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

About Us

"It's about Microsoft Excel"