VBA Autofilter second criteria not working

Llupo01

Active Member
Joined
Aug 17, 2015
Messages
296
Hello all,

I have quick question. I am struggling with autofilter in vba. I have following code:

itm is shift code, which can be xxx, aaa, bbb, ccc etc...

Code:
FilterArr = Array("*" & Itm, "*" & Itm & "/*")
         FilterRng.AutoFilter field:=1, Criteria1:=FilterArr, Operator:=xlFilterValues

which works fine. Problem is, that I can have two identical values but only difference is first letter. For example: I have data set with xxx, 124/xxx, 343/xxx. I want to filter everything, where is xxx...BUT! there can be xxx and also dxxx, which is prloblem, because there will appear xxx and also dxxx values in column. I have tried to use second criteria as follows:
Code:
FilterRng.AutoFilter field:=1, Criteria1:=FilterArr, Operator:=xlAnd, Criteria2:="<>" & "d" & Itm

It does not filter anything. Also tried to create array which want to exclude, also not working.

Can anyone check and let me know, what am I doing wrong? Thank you in advance for any help.

Brgds,
Tom
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top