我在Excel工作表滤波使用.Autofilter数据如下Autofiler为或病症VBA
if bProds = True then
.AutoFilter 4,"<>*strip*",2,"<>*Strip*"
.AutoFilter 8,"Product",2,"product"
else
.AutoFilter 8, "<>Product", 1, "<>product"
.AutoFilter 4,"*strip*",2,"*Strip*"
end if
结果集是行,其中两个自动筛选条件满足。 在else部分,我想做一个条件,使得结果是不包含第8列中的产品/产品的行,或者它包含第4列中的strip/strip。
如果两个条件都是自动过滤器遇到,上面的代码不起作用。任何方式使它像我的要求一样工作?
试验数据也可从this drive.google.com link
表1:
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8
--------- ---- ---- ----- ----- ---- ---- -----
1/07/2015 3 3 Word1 word2 AB Hello Product
1/13/2015 2 1 word2 word1 AB hello product
1/13/2015 2 1 COzier USA Bill Allice Assembly
1/14/2015 3 4 TOny USA Bill Allice Wrox
1/20/2015 2 1 Shawn USA gerard amy Product
1/23/2015 2 1 Wilcox Sanzer Francis Bob Assembly
1/26/2015 3 5 Justin Langer Go febrand Citrix
表2:
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8
--------- ---- ---- ----- ----- ---- ---- -----
1/20/2015 2 1 Shawn USA gerard amy Product
表3:
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8
--------- ---- ---- ----- ----- ---- ---- -----
1/07/2015 3 3 Word1 word2 AB Hello Product
1/13/2015 2 1 word2 word1 AB hello product
1/13/2015 2 1 COzier USA Bill Allice Assembly
1/14/2015 3 4 TOny USA Bill Allice Wrox
1/23/2015 2 1 Wilcox Sanzer Francis Bob Assembly
1/26/2015 3 5 Justin Langer Go febrand Citrix
我不认为,除非你使用一个辅助列,您可以用自动筛选实现这一目标。 [高级过滤](https://support.office.com/en-us/article/Filter-by-using-advanced-criteria-4c9222fe-8529-4cd7-a898-3f16abdff32b#bmexample3)可以实现这一点,如果这是可以接受的解决方案 – barrowc
你能提供最少的前后测试数据吗? –
我可以使用任何构造。由于现有代码正在使用.Autofilter,我只是检查是否有可能使用.Autofilter。使用.AdvanceFilter无问题,只要它达到我想要的.. :)。我做了一个测试文件'https://drive.google.com/open?id = 1fvlZnQ12vodFFqjAHaODXcF0CYFkahBKGUBE7EMt8Uc' – Programmerzzz