VBA Autofilter Question

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
147
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:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
What are the other criteria?
 
Upvote 0
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
 
Upvote 0
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!
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Hello, I am working through an Autofilter issue.

Basically, I am able to autofilter a sheet and copy it to the body of the email and send the email, When I try to add a second autofilter criteria and paste that to the body of the email, it breaks and everything is blank.

VBA Code:
With wsNIM
.AutoFilterMode = False
    With rngNIM
    .AutoFilter Field:=8, Criteria1:="<>"
    .SpecialCells(xlCellTypeVisible).Copy
    End With
End With

'With wsNIM
'.AutoFilterMode = False
    'With rngError
    '.AutoFilter Field:=7, Criteria1:="<>"
    '.SpecialCells(xlCellTypeVisible).Copy
   ' End With
'End With

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        '.To = ""
        .CC = "me@me.com"
        '.BCC = ""
        .Subject = "subjectlinehere"
        .HTMLBody = RangetoHTML(PCReconcilement) & vbNewLine & "Not in Master Record" & vbNewLine & RangetoHTML(rngNIM) '& "Processing Error" & vbNewLine & RangetoHTML(rngError)
        'You can add a file like this
        '.Attachments.Add 
        .Send   'or use .Display
    End With
    On Error GoTo 0

How do I autofilter a second time and add to the body? FYI: RangeToHTML is a function
 
Upvote 0
As this is a different question from the OP, please start a new thread. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,534
Messages
6,120,080
Members
448,943
Latest member
sharmarick

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