View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Piotr Lipski Piotr Lipski is offline
external usenet poster
 
Posts: 36
Default Filter Macro with Cell reference

Dnia Thu, 29 Jun 2006 14:50:30 -0500, chris100 napisał(a):

[...]
Selection.AutoFilter Field:=1, Criteria1:="=*" & Range("M13").Value _
& "*"

I tried playing around with the above but come unstuck when trying to
do a less than or equals to.


Selection.AutoFilter Field:=1, Criteria1:="<=" & Range("M13").Value

[...]
P.s could someone explain what the * element of the code is for?


Look at this code:
Criteria1:="=*" & Range("M13").Value & "*"

If M13 equals to, let's say, "xyz", then this line expands to:
Criteria1:="=*xyz*"

which means "show all records that CONTAIN xyz in field 1"

In the same way you could write:

Criteria1:="=" & Range("M13").Value & "*"

whicg means: all records BEGINNING with xyz in field 1

etc, etc...

--
PL