VBA filters using 3 or more criteria
Results 1 to 4 of 4

Thread: VBA filters using 3 or more criteria
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2019
    Posts
    88
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default VBA filters using 3 or more criteria

    I'm trying to filter using 3 criteria but I'm getting an error, here is the code I tried.

    With ActiveSheet
    .AutoFilterMode = False
    With Range("A2:I2")
    .AutoFilter
    .AutoFilter field:=4, Criteria1:="Text56", Operator:=xlAnd, Criteria2:="Text76", Operator:=xlAnd, Criteria3:="Text80"
    End With
    End With

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,687
    Post Thanks / Like
    Mentioned
    445 Post(s)
    Tagged
    45 Thread(s)

    Default Re: VBA filters using 3 or more criteria

    Try
    Code:
    With ActiveSheet
       .AutoFilterMode = False
       With .Range("A2:I2")
          .AutoFilter 4, Array("Text56", "Text76", "Text80"), xlFilterValues
       End With
    End With
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    Board Regular
    Join Date
    Mar 2019
    Posts
    88
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA filters using 3 or more criteria

    Works perfect, thank you so much, the purpose of the filter was so that I could delete those lines, but my delete is not working,

    Sub Adjust_Report()
    Dim lastrow As Long
    Dim lRow As Long
    Dim Rng As Range
    If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
    Dim fd As Office.FileDialog
    If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
    lRow = ActiveSheet.Range("A500").End(xlUp).Row

    If Range("f3:f" & lRow).SpecialCells(xlCellTypeVisible).Count > 1 Then
    ActiveSheet.Range("a2:j" & lRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    End If
    Last edited by tanyaleblanc; Mar 31st, 2019 at 10:42 AM.

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,687
    Post Thanks / Like
    Mentioned
    445 Post(s)
    Tagged
    45 Thread(s)

    Default Re: VBA filters using 3 or more criteria

    How about
    Code:
    Sub Adjust_Report()
    With ActiveSheet
       .AutoFilterMode = False
       With .Range("A2:I2")
          .AutoFilter 4, Array("Text56", "Text76", "Text80"), xlFilterValues
       End With
       .AutoFilter.Range.Offset(1).EntireRow.Delete
       .AutoFilterMode = False
    End With
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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