Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto filter method of range class failed with Criteria

Tags:

excel

vba

Set rmdvsheet = ActiveWorkbook.Sheets(11)

    rmdvsheet.Range("A1:K103").AutoFilter Field:=10, Criteria1:= _
        "D7u L462-L494 17MY"

Here on 2nd line i am geting an error saying "Auto filter method of range class failed".

like image 614
srt Avatar asked Jan 22 '26 15:01

srt


2 Answers

Your problem is with the range you've defined. The autofilter only wants referral to the header row. If you sub this into your code, it should work the way you expect (the only change is in the range from K103 to K1"):

rmdvsheet.Range("A1:K1").AutoFilter Field:=10, Criteria1:="D7u L462-L494 17MY"
like image 120
Instant Breakfast Avatar answered Jan 24 '26 08:01

Instant Breakfast


I had the same problem. If you are turned to the right sheet and no other syntax error. It's because maybe in the original sheet, it is already autofiltered. Like in the following picture. To solve this, just click the filter button to return to the unfilter status. 1

like image 38
m.w Avatar answered Jan 24 '26 08:01

m.w



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!