+ Reply to Thread
Results 1 to 8 of 8

Combine 2 worksheet change events

Hybrid View

  1. #1
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Combine 2 worksheet change events

    Hi

    I am trying to combine two worksheet change events without any joy;

    Private Sub Worksheet_Change(ByVal Target As Range)
    If [l7] = "Yes" Then
    Sheets("Mobile Tower checklist p10").Visible = True
    Else
    Sheets("Mobile Tower checklist p10").Visible = False
    End If
    Private Sub Worksheet_Change(ByVal Target As Range)
    If [l6] = "Yes" Then
    Sheets("LIFT PLAN").Visible = True
    Else
    Sheets("LIFT PLAN").Visible = False
    End If
    End Sub
    Im sure its a fairly simple fix but im baffled!

    cheers
    Last edited by Cutter; 09-07-2012 at 06:55 PM. Reason: Added code tags

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Combine 2 worksheet change events

    Hi
    Get rid of red part from Your code
    Private Sub Worksheet_Change(ByVal Target As Range)
    If [l7] = "Yes" Then
    Sheets("Mobile Tower checklist p10").Visible = True
    Else
    Sheets("Mobile Tower checklist p10").Visible = False
    End If
    Private Sub Worksheet_Change(ByVal Target As Range)
    If [l6] = "Yes" Then
    Sheets("LIFT PLAN").Visible = True
    Else
    Sheets("LIFT PLAN").Visible = False
    End If
    End Sub
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Combine 2 worksheet change events

    Thanks Tom, greatly appreciated.

    If i wanted to unhide more than one sheet using the second command code, how would i do that?

  4. #4
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Combine 2 worksheet change events

    As in;

    Private Sub Worksheet_Change(ByVal Target As Range)
    If [l7] = "Yes" Then
    Sheets("Mobile Tower checklist p10").Visible = True
    Else
    Sheets("Mobile Tower checklist p10").Visible = False
    End If
    If [l6] = "Yes" Then
    Sheets("LIFT PLAN","lift plan 2", "lift plan 3").Visible = True
    Else
    Sheets("LIFT PLAN","lift plan 2", "lift plan 3").Visible = False
    End If
    End Sub

    is this right?
    Last edited by Cutter; 09-07-2012 at 06:57 PM. Reason: Added code tags

  5. #5
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Combine 2 worksheet change events

    In standard module try this
    Sub aa()
    Dim wk As Worksheet
    For Each wk In ThisWorkbook.Worksheets
    wk.Visible = 1
    Next
    End Sub

  6. #6
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Combine 2 worksheet change events

    Apolgies, my vba experience is in starter mode - where does that element of the code go?

  7. #7
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Combine 2 worksheet change events

    A little information e.g. here:
    http://www.contextures.com/xlvba01.html

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Combine 2 worksheet change events

    @ akderitend

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1