Hello All,
After creating code to copy my filtered data within my raw data tab, I realized there is a value coming back that I would like to exclude. I'm currently filtering on "High", "Moderate-High". HOwever I'm also retrieving the value "Moderate" alone. I'm trying to exclude it with the following code, but I'm receiving a syntax error. I've tried moving the "Criteria2" portion to different areas, but nothing has worked so far.
Any and all help is greatly appreciated. Thanks!
D
After creating code to copy my filtered data within my raw data tab, I realized there is a value coming back that I would like to exclude. I'm currently filtering on "High", "Moderate-High". HOwever I'm also retrieving the value "Moderate" alone. I'm trying to exclude it with the following code, but I'm receiving a syntax error. I've tried moving the "Criteria2" portion to different areas, but nothing has worked so far.
VBA Code:
Sub FilterMultipleCriteria()
'
' On Error Resume Next
' Filter by Multiple Criteria
Application.DisplayAlerts = False
On Error Resume Next
Sheets("Sheet1").Delete
On Error GoTo 0
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Sheet1"
Dim ws As Worksheet
Dim FilterRange As Range
Dim criteriaArray As Variant
Dim CopyRange As Range
Dim DestRange As Range
Dim Cell As Range
Set ws = ThisWorkbook.Sheets("Report Data")
Set FilterRange = ws.Range("E1:EF" & ws.Cells(ws.Rows.Count, "E").End(xlUp).Row)
Set CopyRange = FilterRange.SpecialCells(xlCellTypeVisible)
Set DestRange = Sheets("Sheet1").Range("A1")
criteriaArray = Array("High", "Moderate-High")
With ws
.AutoFilterMode = False
FilterRange.AutoFilter Field:=1, Criteria1:=criteriaArray, _
Operator:=xlFilterValues,
Criteria2:="<>*Moderate*"
End With
CopyRange.Copy DestRange
End Sub
D