pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Hi, I am using below code to filter my data...
but the array when used in another workbook sheet to filter wont filter at all - - - Please advice!
Thanks in advance for looking into this...
but the array when used in another workbook sheet to filter wont filter at all - - - Please advice!
Thanks in advance for looking into this...
Code:
[/FONT]
[FONT=Courier New]Sub Test()
Dim wb As Workbook, MyFile As String
Dim MyArray() As Variant
MyArray = Sheet1.Range("A1:A3")
MyFile = ThisWorkbook.Path & "\Book2.xls"
Set wb = Workbooks.Open(Filename:=MyFile)[/FONT]
[FONT=Courier New]wb.Activate
With Sheets("AllDatas")
.Range("A1:D20").AutoFilter Field:=3, Criteria1:=Application.Transpose(MyArray), Operator:=xlFilterValues
End With[/FONT]
[FONT=Courier New]MsgBox Sheets("AllDatas").Range("A1:A20").SpecialCells(xlCellTypeVisible).Count
Application.DisplayAlerts = False
wb.Close False
Application.DisplayAlerts = True
End Sub