Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

changing tabs from a cell from a difference sheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
duckie - 14 Nov 2007 11:07 GMT
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
Bob Phillips - 14 Nov 2007 11:43 GMT
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

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

>i have try the following but it won't let me  change the tab on sheet
> 2 where i put the code in
[quoted text clipped - 22 lines]
>
> can someone please help me
Joel - 14 Nov 2007 11:59 GMT
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"

> i have try the following but it won't let me  change the tab on sheet
> 2 where i put the code in
[quoted text clipped - 22 lines]
>
> can someone please help me
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.