VBA - Setting the AutoFilter function

September 2017


I have a problem with a macro, I want apply a filter on a field so that when I enter a value from the keyboard, the filtering is done with a condition "other than" cthis setting, for example: when I 'uses a preset such as: Selection.AutoFilter Field:=6, Criteria1:="<>2 , filtering in this case will be made based display any value different from 2.
I do not want a constant value "2" but a value that is entered from the keyboard example:
X = InputBox ("...")
Y = Val(x)
Selection.AutoFilter Field:=6, Criteria1:= "<>y"


Try this:
Criteria1:="<>" & y
Thanks to chossette9 for this tip.


Published by aakai1056. Latest update on September 12, 2011 at 11:20 AM by aakai1056.
This document, titled "VBA - Setting the AutoFilter function," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).