ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help: Autofilter doesn't work (https://www.excelbanter.com/excel-programming/275611-help-autofilter-doesnt-work.html)

Sebastian[_2_]

Help: Autofilter doesn't work
 
I need to filter data in a sheet using a string as
criteria.

The problem I encountered is I get the string in this way:

Set mycell = Sheets("DPC").Range("Q3")

where in cell Q3 I insert a string key to perfom filtering.

If I use this code it obviously doesn't work, as it look
for "my_value" not for the value itself

Selection.AutoFilter Field:=3, Criteria1:="=my_value",
Operator:=xlAnd

Whay can I do?

Thanks Sebastian

Tom Ogilvy

Autofilter doesn't work
 
Set mycell = Sheets("DPC").Range("Q3")


Selection.AutoFilter Field:=3, Criteria1:= "=" & mycell.Value, _
Operator:=xlAnd

--
Regards,
Tom Ogilvy

"Sebastian" wrote in message
...
I need to filter data in a sheet using a string as
criteria.

The problem I encountered is I get the string in this way:

Set mycell = Sheets("DPC").Range("Q3")

where in cell Q3 I insert a string key to perfom filtering.

If I use this code it obviously doesn't work, as it look
for "my_value" not for the value itself

Selection.AutoFilter Field:=3, Criteria1:="=my_value",
Operator:=xlAnd

Whay can I do?

Thanks Sebastian




Sebastian[_2_]

Autofilter doesn't work
 
Thanks,

Sebastian


Selection.AutoFilter Field:=3, Criteria1:= "=" &

mycell.Value, _
Operator:=xlAnd

--
Regards,
Tom Ogilvy

"Sebastian" wrote in message
...
I need to filter data in a sheet using a string as
criteria.

The problem I encountered is I get the string in this

way:

Set mycell = Sheets("DPC").Range("Q3")

where in cell Q3 I insert a string key to perfom

filtering.

If I use this code it obviously doesn't work, as it look
for "my_value" not for the value itself

Selection.AutoFilter Field:=3, Criteria1:="=my_value",
Operator:=xlAnd

Whay can I do?

Thanks Sebastian



.



All times are GMT +1. The time now is 05:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com