VBA to filter within a filter

thardin

Board Regular
Joined
Sep 29, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Here is code I have to filter column M for 046s that is mostly working.
However, the Else part of my If statement isn't working, where if there are 046s I want to do a further filter and filter those 046s by column 8 for the values listed in the code.
How do I fix this?

VBA Code:
Sub Filter046()
'
' Filter046 Macro
'
' Keyboard Shortcut: Ctrl+d
'
With ActiveSheet
   .Range("A1:N1").AutoFilter Field:=13, Criteria1:="046"
   If .AutoFilter.Range.Columns(1).SpecialCells(xlVisible).Count = 1 Then
      
    Application.Run "'PERSONAL(1).xlsb'!FirmSignoff"
      'ActiveWorkbook.Close SaveChanges:=True
      
    Else
        ActiveSheet.Range("$A$1:$N$151").AutoFilter Field:=8, Criteria1:= _
        "=367,360,398", Operator:=xlOr, Criteria2:="=700,701,702,703,707"
   End If
End With


End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
How about
VBA Code:
ActiveSheet.Range("$A$1:$N$151").AutoFilter 8, Array("367", "360", "398", "700", "701", "702", "703", "707"), xlFilterValues
 
Upvote 0
Solution

Forum statistics

Threads
1,214,978
Messages
6,122,547
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top