VBA programming-autofilter function

  • Thread starter Thread starter ylchuah
  • Start date Start date
Y

ylchuah

Hi,

I have 2 worksheet=> A & B
I want to filter data in worksheet A, which the criterial is the value
in certain cell in worksheet B.

I have try the below method to filter a column which contain only "0" &
"1"
Selection.AutoFilter Field:=7, Criteria1:="0"
it work..

but when i use the same command which i change the criterial to some
text, then error happen.

And i found some syntax like
Filter(sourcesrray, match[, include[, compare]])
but i dun understand the line of syntax..

pls help...

Thanks
YL Chuah
 
Hi Ylchuah,

I want to filter data in worksheet A, which the criterial is the value
in certain cell in worksheet B.
[cut]

but when i use the same command which i change the criterial to some
text, then error happen.

Using a text value on a second sheet as a criterion for an autofilter on a
first sheet, the following worked for me:

Public Sub Tester02A()
Dim DataSh As Worksheet
Dim CritSh As Worksheet

With ActiveWorkbook
Set DataSh = .Sheets("Sheet1")
Set CritSh = .Sheets("Sheet2")
End With

DataSh.ShowAllData

DataSh.Cells.AutoFilter _
Field:=7, _
Criteria1:=">" & CritSh.Range("A1").Value

End Sub


---
Regards,
Norman



ylchuah said:
Hi,

I have 2 worksheet=> A & B
I want to filter data in worksheet A, which the criterial is the value
in certain cell in worksheet B.

I have try the below method to filter a column which contain only "0" &
"1"
Selection.AutoFilter Field:=7, Criteria1:="0"
it work..

but when i use the same command which i change the criterial to some
text, then error happen.

And i found some syntax like
Filter(sourcesrray, match[, include[, compare]])
but i dun understand the line of syntax..

pls help...

Thanks
YL Chuah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top