Hi,
I have a code for a filter but I get an error message.
Error message says:
Run-time error
Method 'Autofilter' of object 'Range' failed.
Code below:
I cannot figure out how to fix this if someone can offer some help.
Thanks,
N.
I have a code for a filter but I get an error message.
Error message says:
Run-time error
Method 'Autofilter' of object 'Range' failed.
Code below:
VBA Code:
Sub ApplyFilter()
Dim filterRange As Range
Dim filterConditions As Range
'Set the filter range and conditions range
Set filterRange = Sheets("Sheet2").Range("B11:F1000")
Set filterConditions = Sheets("Sheet1").Range("A4:A" & Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row)
'Clear any existing filters
filterRange.AutoFilter
'Apply the filter based on the conditions in Sheet1
filterRange.AutoFilter Field:=2, Criteria1:=filterConditions, Operator:=xlFilterValues
End Sub
I cannot figure out how to fix this if someone can offer some help.
Thanks,
N.