VBA Autofilter Question

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
106
Hi all, I am using the following code to filter some data and delete it, but I need to put in multiple criteria's, and I am not sure how to do that, please help! The section in bold is where i need to add multiple items.
VBA Code:
With Sheets("Pivot")
.AutoFilterMode = False
With .Range("D", .Range("D" & Rows.Count).End(xlUp))
.AutoFilter 1, "0"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,074
Office Version
  1. 365
Platform
  1. Windows
What are the other criteria?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,074
Office Version
  1. 365
Platform
  1. Windows
Ok, try it like
VBA Code:
Dim Ary As Variant
Ary = Array("0", "912", "3905", "843", "1200", "9049", "9032", "852", "835", "2013")
With Sheets("Pivot")
   .AutoFilterMode = False
   .Range("D", .Range("D" & Rows.Count).End(xlUp)).AutoFilter 1, Ary, xlFilterValues
   .AutoFilter.Range.Offset(1).EntireRow.Delete
   .AutoFilterMode = False
End With
Just add the rest of the values to the array
 

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
106
Ok, try it like
VBA Code:
Dim Ary As Variant
Ary = Array("0", "912", "3905", "843", "1200", "9049", "9032", "852", "835", "2013")
With Sheets("Pivot")
   .AutoFilterMode = False
   .Range("D", .Range("D" & Rows.Count).End(xlUp)).AutoFilter 1, Ary, xlFilterValues
   .AutoFilter.Range.Offset(1).EntireRow.Delete
   .AutoFilterMode = False
End With
Just add the rest of the values to the array
Perfect as always! Thank you Sir, very much!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,074
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,907
Messages
5,544,984
Members
410,647
Latest member
LegenDSlayeR
Top