AutoFilter Criteria Array Only Returns Data For One Element

wsnyder

Board Regular
Joined
Sep 23, 2018
Messages
131
Hi all,

Using excel 365.

AutoFilter uses a Criteria Array, but only returning data for one of the elements of the array, nothing for the 2nd element.
I added a debug.print command to check the Array and both items are returned.
I reviewed the data and there are records in the data that match both array elements.

I am transferring a Range to the Array in case that might be the issue.
VBA Code:
            'Transfer criteria range to criteria array
                arr = rngCriteria

I tested the contents of the array. The contents are correct

VBA Code:
            For i = LBound(arr) To UBound(arr)
                Debug.Print i, arr(i, 1)
            Next i

Here is the AutoFilter snippet. It is only returning records that match the first element of the criteria array

VBA Code:
            lo.Range.AutoFilter _
                        Field:=5, _
                        Criteria1:=arr, _
                        Operator:=xlFilterValues

Thanks,
-w
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

NoSparks

Well-known Member
Joined
Mar 15, 2013
Messages
1,273
Office Version
  1. 2010
Platform
  1. Windows
maybe
VBA Code:
 arr = application.transpose(rngCriteria)
 
Solution

NoSparks

Well-known Member
Joined
Mar 15, 2013
Messages
1,273
Office Version
  1. 2010
Platform
  1. Windows
You're welcome, thanks for reporting back.
 

Forum statistics

Threads
1,147,747
Messages
5,742,966
Members
423,769
Latest member
LongToast

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
Top