excel VBA - filter table with an array

RCBricker

Well-known Member
Joined
Feb 4, 2003
Messages
1,560
I am trying to filter a table with an array, but the table is only being filtered by the last element. What am I doing wrong?

Code:
dim varI as variant, arrT() as variant
dim ws1 as worksheet
Dim loTBL As ListObject
Dim intSGL As Integer


arrT = Array("101000", "109000", "131000", "131900")
For Each varI In arrT
Debug.Print varI
Next varI
20126           ws1.AutoFilterMode = False

20127           loTBL.Range.AutoFilter Field:=intSGL, Criteria1:=arrT
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try
Code:
loTBL.Range.AutoFilter intSGL, arrT, xlFilterValues
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,703
Members
452,667
Latest member
vanessavalentino83

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