PC Review


Reply
Thread Tools Rate Thread

changing tabs from a cell from a difference sheet

 
 
duckie
Guest
Posts: n/a
 
      14th Nov 2007
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      14th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      14th Nov 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing tab from another sheet cell duckie Microsoft Excel Worksheet Functions 6 14th Nov 2007 04:55 PM
Changing Excell Sheet Tabs to Different Colors =?Utf-8?B?QW15?= Microsoft Excel Misc 4 8th Mar 2007 11:19 PM
Name sheet tabs with a cell list =?Utf-8?B?ZGVlZHM=?= Microsoft Excel Misc 2 9th Jun 2006 04:22 PM
How can I make the names for Sheet tabs a reference to a cell? =?Utf-8?B?UERT?= Microsoft Excel Misc 2 5th May 2006 11:20 PM
changing a cell value in a different sheet from several sheets Ooz Microsoft Excel Programming 3 26th Aug 2003 03:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.