Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i have try the following but it won't let me change the tab on sheet
2 where i put the code in i want cell A1 on sheet 1 to change tab on sheet 2 the only way it will change is if i type something in A! on sheet 2 Private Sub Worksheet_Change(ByVal Target As Excel.Range) Const sNAMECELL As String = "A1" Const sERROR As String = "Invalid worksheet name in cell " Dim sSheetName As String With Target If Not Intersect(.Cells, Range(sNAMECELL)) Is Nothing Then sSheetName = Sheets("Sheet1").Range(sNAMECELL).Value If Not sSheetName = "" Then On Error Resume Next Me.Name = sSheetName On Error GoTo 0 If Not sSheetName = Me.Name Then _ MsgBox sERROR & sNAMECELL End If End If End With End Sub can someone please help me |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sNAMECELL As String = "A1" Const sERROR As String = "Invalid worksheet name in cell " Dim sSheetName As String With Target If Not Intersect(Target, Me.Range(sNAMECELL)) Is Nothing Then sSheetName = Target.Value If Not sSheetName = "" Then On Error Resume Next Me.Name = sSheetName On Error GoTo 0 If Not sSheetName = Me.Name Then _ MsgBox sERROR & sNAMECELL End If End If End With End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "duckie" wrote in message ups.com... i have try the following but it won't let me change the tab on sheet 2 where i put the code in i want cell A1 on sheet 1 to change tab on sheet 2 the only way it will change is if i type something in A! on sheet 2 Private Sub Worksheet_Change(ByVal Target As Excel.Range) Const sNAMECELL As String = "A1" Const sERROR As String = "Invalid worksheet name in cell " Dim sSheetName As String With Target If Not Intersect(.Cells, Range(sNAMECELL)) Is Nothing Then sSheetName = Sheets("Sheet1").Range(sNAMECELL).Value If Not sSheetName = "" Then On Error Resume Next Me.Name = sSheetName On Error GoTo 0 If Not sSheetName = Me.Name Then _ MsgBox sERROR & sNAMECELL End If End If End With End Sub can someone please help me |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your problem is with the intersect statement
If Not Intersect(.Cells, Range(sNAMECELL)) Is Nothing Then You have a double negative. this stement is equivalent to If Intersect(.Cells, Range(sNAMECELL)) Then ..Cells is the location where you changed the data and sNamecell is defined as "A1" duckie" wrote: i have try the following but it won't let me change the tab on sheet 2 where i put the code in i want cell A1 on sheet 1 to change tab on sheet 2 the only way it will change is if i type something in A! on sheet 2 Private Sub Worksheet_Change(ByVal Target As Excel.Range) Const sNAMECELL As String = "A1" Const sERROR As String = "Invalid worksheet name in cell " Dim sSheetName As String With Target If Not Intersect(.Cells, Range(sNAMECELL)) Is Nothing Then sSheetName = Sheets("Sheet1").Range(sNAMECELL).Value If Not sSheetName = "" Then On Error Resume Next Me.Name = sSheetName On Error GoTo 0 If Not sSheetName = Me.Name Then _ MsgBox sERROR & sNAMECELL End If End If End With End Sub can someone please help me |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
tabs are missing even though 'tools-options-view-sheet tabs' ok? | Excel Worksheet Functions | |||
changing tab from another sheet cell | Excel Worksheet Functions | |||
Changing Excell Sheet Tabs to Different Colors | Excel Discussion (Misc queries) | |||
Name sheet tabs with a cell list | Excel Discussion (Misc queries) | |||
How can I make the names for Sheet tabs a reference to a cell? | Excel Discussion (Misc queries) |