LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Automatically update SheetName in workbook sub if SheetName changes

Hi
I'm using a fairly basic code to get a sheet name to equal a cell in a
worksheet.

Private Sub unpro()
Sub Worksheet_SelectionChange(ByVal Target As Range)
Unprotect "provision"
ActiveSheet.Name = Range("g3").Value
Protect Password:="provision"
End Sub

However when range G3 changes, the following code (in ThisWorkbook)
fails - particularly at:
ThisWorkbook.Sheets("Area").Visible = xlSheetVeryHidden

ThisWorkbook code is:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
HideSheets
End Sub


Private Sub Workbook_Open()
UnhideSheets
End Sub


Private Sub HideSheets()
Dim sht As Object
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Warning").Visible = xlSheetVisible
'This sheet contains a message to the user.
For Each sht In ThisWorkbook.Sheets
If sht.Name < "Warning" Then sht.Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
Next sht
ThisWorkbook.Save
End Sub


Private Sub UnhideSheets()
Dim sht As Object
Application.ScreenUpdating = False
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
Next sht
ThisWorkbook.Sheets("Area").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
End Sub

So of course, what I'd ideally need is for the workbook code to
recognise when the worksheet private sub changes the name of the tab.
E.g. SheetName "Area" might change to SheetName "Zone".

Any help would be appreciated. Please note I'm a VB novice and
knowledge is less than rudimentary.

Thanks
 
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
Does anyone see this .xls]sheetname? Eric Excel Worksheet Functions 2 January 21st 07 03:28 PM
Does anyone see this .xls]sheetname? Eric Excel Discussion (Misc queries) 2 January 21st 07 03:04 PM
Sheetname formula John S Excel Worksheet Functions 3 December 5th 06 07:34 PM
i need the sheetname in my cells Kiklop Excel Worksheet Functions 5 September 15th 06 06:35 PM
Returning Sheetname Andrew Excel Discussion (Misc queries) 5 May 26th 05 11:54 AM


All times are GMT +1. The time now is 02:14 AM.

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"