How to filter a table by a list. My code shows an error

Ashkelon

New Member
Joined
Dec 19, 2020
Messages
19
Office Version
  1. 365
Platform
  1. Windows
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

1608607985932.png


Book1
ABC
2Order IdAccount NoISN No
31362F000045U898709909414121189
44164F000081U898709910414145371
56600FR00089U898709910414142401
68062F000175U898709911414170663
78810F000307U898709911414168817
88855F000311U898709909414121232
98851F000310U898709911414170821
109893F000322U898709911414170993
1110659FR00034U898709910414145414
1210658FR00034U898709911414168763
139671FR00034U898709911414168753
1410794FR00089U898709911414171071
1511089FR00034U898709911414171017
1611091FR00034U898709911414170996
1711289FR00034U898709911414170998
Sheet1


Book1
A
1898709910414145371
2898709911414168817
3898709911414171017
Sheet2
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
It should be Criteria1 not Criteria
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top