Results 1 to 4 of 4

Thread: Filter Sheet With date

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    Take a look at the attached which has the following in the first sheet's code module:
    [vba]Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$I$2" Then
    Range("B3:C37").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:F2"), Unique:=False
    End If
    End Sub[/vba]The data range could be a list (aka table post xl2003) which would mean it would still all be filtered if the list was added to. I've done this on the second sheet with this code behind it:
    [vba]Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$I$2" Then
    ListObjects("List1").Range.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:F2"), Unique:=False
    End If
    End Sub[/vba] You could even make it a dynamic named range instead.
    The criteria range doesn't need to be on the same sheet.

    You can do something similar with an autofilter but the code would be a bit more complex (to make it robust).
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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