Updating Worksheet Tabs

cdsaroma

Board Regular
Joined
Feb 5, 2003
Messages
200
Hi,

I have worksheet 1 (Attendance) which has names (last, first) in rows 4-20 and columns B-C

On worksheet 2 (client name) I have in cell H5 this formula:
Code:
=Attendance!C4&" "&Attendance!B4
which is the Client Name
This part works fine.

I also have code:
Code:
Private Sub Workbook_Open()
Application.StatusBar = ""
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$H$5" Then Sh.Name = Target
End Sub
(placed in 'thisworkbook') that names the sheet tab the value of worksheet 2, cell H5, therefore the client name.

My problem.
If I change the client name on sheet one, it updates on sheet 2 but the sheet tab does not update unless I double-click (activate) cell H5 (on sheet 2).

Any ideas how to get this to update automatically when I re-open the sheet?

thanks
Paul
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Sh.Name = "Attendance" Then
        If Not Intersect(Range("B4:C4"), Target) Is Nothing Then
            Sheets(2).Name = Range("C4").Value & " " & Range("B4").Value
        End If
    End If
End Sub
 
Upvote 0
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Sh.Name = "Attendance" Then
        If Not Intersect(Range("B4:C4"), Target) Is Nothing Then
            Sheets(2).Name = Range("C4").Value & " " & Range("B4").Value
        End If
    End If
End Sub

Thanks for that but I still still have an issue.
That code is good for sheet 2 (which represents client name in B4/C4, how do I implement it so if I change Attendance B5/C5 it updates sheet 3 etc...?

thanks
 
Upvote 0
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim r As Long
    If Sh.Name = "Attendance" Then
        If Target.Count = 1 Then
            If Not Intersect(Range("B4:C10"), Target) Is Nothing Then
                r = Target.Row
                If Len(Range("C" & r).Value & Range("B" & r)) > 0 Then
                    Sheets(r - 2).Name = Range("C" & r).Value & " " & Range("B" & r).Value
                End If
            End If
        End If
    End If
End Sub


You could put this in the "Attendance" worksheet module instead of the ThisWorkbook module.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Long
    If Target.Count = 1 Then
        If Not Intersect(Range("B4:C10"), Target) Is Nothing Then
            r = Target.Row
            If r - 2 <= Sheets.Count Then
                If Len(Range("C" & r).Value & Range("B" & r)) > 0 Then
                    Sheets(r - 2).Name = Range("C" & r).Value & " " & Range("B" & r).Value
                End If
            End If
        End If
    End If
End Sub
 
Last edited:
Upvote 0
Perfect!
Thanks very much :)


Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim r As Long
    If Sh.Name = "Attendance" Then
        If Target.Count = 1 Then
            If Not Intersect(Range("B4:C10"), Target) Is Nothing Then
                r = Target.Row
                If Len(Range("C" & r).Value & Range("B" & r)) > 0 Then
                    Sheets(r - 2).Name = Range("C" & r).Value & " " & Range("B" & r).Value
                End If
            End If
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,248
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top