#1   Report Post  
Tom Hewitt
 
Posts: n/a
Default Tab Names

I've taken a suggested VBA code from the discussion groups;

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$5" Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$5" Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub


This as you can see changes the tab name into cell B5. My problem now is B5
on each tab used it linked into a lookup forumla which looks onto an options
tab, which defines where to look for each code. These formulas work fine and
change through to all the right numbers on each B5 cell. However the Tab
name doesnt change until I actually go into that cell and link back into A2
which is the cells its linked to.

Hope that all makes sense. Any suggestions or if you need more info let me
know
  #2   Report Post  
Tom Hewitt
 
Posts: n/a
Default

Little amendment, I didnt mean to post the VBA code twice, its just in there
the once

Cheers
Tom

"Tom Hewitt" wrote:

I've taken a suggested VBA code from the discussion groups;

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$5" Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$5" Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub


This as you can see changes the tab name into cell B5. My problem now is B5
on each tab used it linked into a lookup forumla which looks onto an options
tab, which defines where to look for each code. These formulas work fine and
change through to all the right numbers on each B5 cell. However the Tab
name doesnt change until I actually go into that cell and link back into A2
which is the cells its linked to.

Hope that all makes sense. Any suggestions or if you need more info let me
know

  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

Worksheet_change reacts nicely to typing changes--but not to changes because of
recalculation.

Option Explicit
Private Sub Worksheet_Calculate()

On Error GoTo ws_exit:
Application.EnableEvents = False
If LCase(Me.Name) < LCase(Me.Range("B5").Value) Then
Me.Name = Me.Range("b5").Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

But if you're duplicating this code in each worksheet module, maybe just having
it once behind the ThisWorkbook would be better.

Option Explicit
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
On Error GoTo ws_exit:
Application.EnableEvents = False
If LCase(Sh.Name) < LCase(Sh.Range("B5").Value) Then
Sh.Name = Sh.Range("b5").Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

Tom Hewitt wrote:

I've taken a suggested VBA code from the discussion groups;

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$5" Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$B$5" Then
Me.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

This as you can see changes the tab name into cell B5. My problem now is B5
on each tab used it linked into a lookup forumla which looks onto an options
tab, which defines where to look for each code. These formulas work fine and
change through to all the right numbers on each B5 cell. However the Tab
name doesnt change until I actually go into that cell and link back into A2
which is the cells its linked to.

Hope that all makes sense. Any suggestions or if you need more info let me
know


--

Dave Peterson
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
sorting names alphabetically when names may start with numbers John Smith Excel Discussion (Misc queries) 3 May 11th 05 08:06 PM
Tab Names II JohnUK Excel Discussion (Misc queries) 1 March 7th 05 03:00 PM
how can I count distinct names in an excel list? RPC@Frito Excel Discussion (Misc queries) 5 February 3rd 05 09:12 PM
Pull unique names for drop down list [email protected] Excel Discussion (Misc queries) 3 February 1st 05 10:23 PM
How can I find the common names in two columns of names? hako Excel Discussion (Misc queries) 2 December 8th 04 01:59 AM


All times are GMT +1. The time now is 01:07 PM.

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"