I am trying to exclude the data but i am facing a road block on Field:=5, rest of the Field is all perfect, on Field:=5 it will exclude the data form the list M3:M7, but no luck.
any way out.
any way out.
VBA Code:
Sub ExcludeDailyRawData()
Dim ws As Worksheet
Dim reportSheet As Worksheet
Dim exclusionRange As Range
Dim exclusionValues As Variant
Dim cell As Range
Dim criteriaArray() As String
Dim i As Integer
' Set the sheets
Set ws = ThisWorkbook.Sheets("Daily-RawData")
Set reportSheet = ThisWorkbook.Sheets("Report")
' Clear any existing filters
If ws.AutoFilterMode Then ws.AutoFilterMode = False
' Retrieve exclusion values from Report sheet, range M3:M7
Set exclusionRange = reportSheet.Range("M3:M7")
exclusionValues = exclusionRange.Value
' Initialize the criteria array
ReDim criteriaArray(1 To UBound(exclusionValues, 1))
' Populate the criteria array
i = 1
For Each cell In exclusionRange
criteriaArray(i) = cell.Value
i = i + 1
Next cell
' Apply autofilter to column F
ws.Range("A1").AutoFilter Field:=6, Criteria1:="<>" & "Day"
' Apply autofilter to column G
ws.Range("A1").AutoFilter Field:=7, Criteria1:="<>" & "All Fixed", Operator:=xlAnd, Criteria2:="<>" & "Fiber"
' Apply autofilter to column D
ws.Range("A1").AutoFilter Field:=4, Criteria1:="<>" & "administrative_area_level_1", Operator:=xlAnd, Criteria2:="<>" & "country"
' Apply autofilter to column E to exclude specific values from the criteria array
ws.Range("A1").AutoFilter Field:=5, Criteria1:="<>" & criteriaArray, Operator:=xlFilterValues
MsgBox "Filters have been applied to the 'Daily-RawData' sheet.", vbInformation
End Sub