PDA

View Full Version : Autofilter with VBA



pimentamarqu
08-17-2010, 11:27 PM
Dear all,

I've started with VBA a couple of month ago and i'm getting some difficulties creating a code to filter a data base using another cell as a "contain" criteria.
I don't have problems if i use the cell as criteria:


ActiveSheet.Range("$A$6:$AY$5008").AutoFilter Field:=1, Criteria1:=Range("informe_iso!A1")


but if i try to used a cell to filter as "contain" criteria it it will give me a compile error:


ActiveSheet.Range("$A$6:$AY$5008").AutoFilter Field:=1, Criteria1:=*Range("informe_iso!A1")*


ths for your help

Bob Phillips
08-18-2010, 12:31 AM
Have you tried



ActiveSheet.Range("$A$6:$AY$5008").AutoFilter Field:=1, Criteria1:="*" & Range("informe_iso!A1").Value & "*"

pimentamarqu
08-18-2010, 02:28 AM
Tks, it's working