VBA - Setting the AutoFilter function

December 2016


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.

Related :

This document entitled « VBA - Setting the AutoFilter function » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.