Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default changing tabs from a cell from a difference sheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default changing tabs from a cell from a difference sheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default changing tabs from a cell from a difference sheet

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
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
tabs are missing even though 'tools-options-view-sheet tabs' ok? rgranell Excel Worksheet Functions 3 August 16th 08 04:25 PM
changing tab from another sheet cell duckie Excel Worksheet Functions 6 November 14th 07 04:55 PM
Changing Excell Sheet Tabs to Different Colors Amy Excel Discussion (Misc queries) 4 March 8th 07 11:19 PM
Name sheet tabs with a cell list deeds Excel Discussion (Misc queries) 2 June 9th 06 04:22 PM
How can I make the names for Sheet tabs a reference to a cell? PDS Excel Discussion (Misc queries) 2 May 5th 06 11:20 PM


All times are GMT +1. The time now is 07:57 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"