Results 1 to 3 of 3

Thread: Conditionally Manage Multiple Items In Worksheet_Change(ByVal Target As Range) Event

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14

    Conditionally Manage Multiple Items In Worksheet_Change(ByVal Target As Range) Event

    Hi,
    I am using the below code to change the filter in range "B11:K11" based on a dropdown in cell C1 and it is working fine. I want to add another event in the same code targeting range "G12:G31" and "I12:I31" triggering MsgBox "Test".

    HTML Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address = "$C$1" Then
    
    If Range("C1") = "All" Then
    ActiveSheet.AutoFilterMode = False
    Else
    ActiveSheet.AutoFilterMode = False
    ActiveSheet.Range("B11:K11").Select
    Selection.AutoFilter 1, ActiveSheet.Range("C1").Value
    
    
    End If
    End If
    
    End Sub
    Thanks
    Raj

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    try something like

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Target.Address = "$C$1" Then
            If Range("C1") = "All" Then
                ActiveSheet.AutoFilterMode = False
            Else
                ActiveSheet.AutoFilterMode = False
                ActiveSheet.Range("B11:K11").Select
                Selection.AutoFilter 1, ActiveSheet.Range("C1").Value
            End If
            
        ElseIf Not Application.Intersect(Target, Range("G12:G31")) Is Nothing Then
            'your action here
        ElseIf Not Application.Intersect(Target, Range("I12:I31")) Is Nothing Then
            'your action here
        End If
    
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    Awesome, working great

    Thanks again
    Raj

Similar Threads

  1. Replies: 10
    Last Post: 10-17-2013, 07:36 PM
  2. Target.Value help in Worksheet_Change
    By ProspectiveCounselor in forum Excel Help
    Replies: 3
    Last Post: 07-24-2013, 05:00 AM
  3. Replies: 14
    Last Post: 06-27-2013, 10:57 AM
  4. Worksheet_Change event
    By Excelfun in forum Excel Help
    Replies: 2
    Last Post: 11-21-2012, 07:24 AM
  5. Event target range
    By bobkap in forum Excel Help
    Replies: 3
    Last Post: 09-13-2012, 05:34 AM

Posting Permissions

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