View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default VBA programming-autofilter function

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" wrote in
message ...

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


--
ylchuah
------------------------------------------------------------------------
ylchuah's Profile:
http://www.excelforum.com/member.php...o&userid=25341
View this thread: http://www.excelforum.com/showthread...hreadid=388216