A few words of thanks would be greatly appreciated.

VBA - Setting the AutoFilter function

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.

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Published by . Latest update on 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 (https://ccm.net/).