My code of filtering a table in Sheet1 (using Column C as a filter) by a dynamic list in Sheet2 is throwing an error. I've attached the L2BB sheets at the bottom. I'm also open to other suggestions of filtering a table by a dynamic range
VBA Code:
Public Sub FilterList()
Dim count As Integer
Dim list As Variant
Sheet2.Activate
count = WorksheetFunction.CountA(Range("A1", Range("A1").End(xlDown)))
list = Range(Cells(1, 1), Cells(count, 1)).Value
list = Application.Transpose(list)
list = Join(list, ",")
list = Split(list, ",")
Sheet1.Activate
'Debugger highlights this next line of code when throwing up the error
ActiveSheet.Range("A2").AutoFilter Field:=3, Criteria:=list, Operator:=xlFilterValues
End Sub
Book1 | |||||
---|---|---|---|---|---|
A | B | C | |||
2 | Order Id | Account No | ISN No | ||
3 | 1362 | F000045U | 898709909414121189 | ||
4 | 4164 | F000081U | 898709910414145371 | ||
5 | 6600 | FR00089U | 898709910414142401 | ||
6 | 8062 | F000175U | 898709911414170663 | ||
7 | 8810 | F000307U | 898709911414168817 | ||
8 | 8855 | F000311U | 898709909414121232 | ||
9 | 8851 | F000310U | 898709911414170821 | ||
10 | 9893 | F000322U | 898709911414170993 | ||
11 | 10659 | FR00034U | 898709910414145414 | ||
12 | 10658 | FR00034U | 898709911414168763 | ||
13 | 9671 | FR00034U | 898709911414168753 | ||
14 | 10794 | FR00089U | 898709911414171071 | ||
15 | 11089 | FR00034U | 898709911414171017 | ||
16 | 11091 | FR00034U | 898709911414170996 | ||
17 | 11289 | FR00034U | 898709911414170998 | ||
Sheet1 |
Book1 | |||
---|---|---|---|
A | |||
1 | 898709910414145371 | ||
2 | 898709911414168817 | ||
3 | 898709911414171017 | ||
Sheet2 |