All,
I'm trying to filter items on a sheet based on a range of data that gets input from another sheet. My current macro is only filtering based on the 1st cell in that range.
The range I'd like it to filter based on will change day to day. Some days it may be 3 items some days it may be 7. So I am not able to just have the filter look at 4 specific cells.
Here is what I currently have and I am not sure why it isn't filtering based off all 4 cells, instead it is only filtering based on the 1st cell in that range.
Dim POinput As Range, cell As Range
Dim lrow As Integer
Dim arrList() As String, lngcnt As Long
With Sheets("Control")
lrow = Range("A50").End(xlUp).Row
Set POinput = .Range("A5:A" & lrow)
End With
lngcnt = 0
For Each cell In POinput
ReDim Preserve arrList(lngcnt)
arrList(lngcnt) = cell.Text
lngcnt = lngcnt + 1
Next
Sheets("ACTOpenItems").Select
ActiveSheet.Range("A1:FH" & lastrow).AutoFilter Field:=2, Criteria1:=arrList, _
Operator:=xlFilterValues
For example assume I've entered the data in "Control" tab of 1 and 3 because these are the items I want to filter on in column B of the "ACTOpenItems" tab.
The ACTOpenItems tab looks like this.
Type / Acct / Amount
Dog / 1 / 100
Cat / 2 / 150
Bird / 3 / 200
Dog / 4 / 250
Cat / 1 / 300
Bird / 2 / 350
Dog / 3 / 400
Cat / 4 / 450
Bird / 1 / 500
Dog / 2 / 550
Cat / 3 / 600
Bird / 4 / 650
And I want the results of.
Type / Acct / Amount
Dog / 1 / 100
Bird / 3 / 200
Cat / 1 / 300
Dog / 3 / 400
Bird / 1 / 500
Cat / 3 / 600
Thank you in advance for any help.
ReDim arrList(POinput.Cells.Count)
.ReDim Preserve
never seems to work as intended for me. – user3819867