Hi,
I'm trying to select multiple criteria within the same column from my data set. I continue to receive a 1004 Run-time error for the following code. When I select debug the following line highlights:
Sheets("Report Data").Range("E1:E").AutoFilter Field:=5, Criteria1:=criteriaArray, _
Operator:=xlFilterValues
I've been unable to figure out how to properly utilize an array within my code:
Any help is greatly appreciated! Thank you so much.
D.
I'm trying to select multiple criteria within the same column from my data set. I continue to receive a 1004 Run-time error for the following code. When I select debug the following line highlights:
Sheets("Report Data").Range("E1:E").AutoFilter Field:=5, Criteria1:=criteriaArray, _
Operator:=xlFilterValues
I've been unable to figure out how to properly utilize an array within my code:
VBA Code:
Sub FilterMultipleCriteria()
'
' On Error Resume Next
' Filter by Multiple Criteria
Dim ws As Worksheet
Dim FilterRange As Range
Dim criteriaArray As Variant
Set ws = ThisWorkbook.Sheets("Report Data")
Set FilterRange = ws.Range("E1:E" & ws.Cells(ws.Rows.Count, "E").End(xlUp).Row)
criteriaArray = Array("High", "Moderate-High")
With ws
.AutoFilterMode = False
Sheets("Report Data").Range("E1:E").AutoFilter Field:=5, Criteria1:=criteriaArray, _
Operator:=xlFilterValues
End With
' If Err.Numer <> 0 Then
' MsgBox "Error: " & _
'Err.Description
' End If
End Sub
Any help is greatly appreciated! Thank you so much.
D.