Hi guys! Taking my first steps in working with arrays. I'm trying to load a dynamic array as an autofilter criteria, but I must be missing something. Found some hints Googling around, but couldn't make it work. I will get the filter marker in the right column, but no filtering results. Array is loaded from "Helper_table" and running the filter in "Target_table"
When checking array contents with MsgBox, I see the correct values presented, so the correct data seems to be loaded
Or do I still need to run some maintenance on my values? Have I perhaps loaded the array incorrectly?
The filtering will work if I hardcode the array, however that's not really useful in this instance:
Code:
Sub Filter_array()
Dim myArray() As Variant
Dim myTable As ListObject
Set myTable = ActiveSheet.ListObjects("Helper_table")
TempArray = myTable.DataBodyRange.Columns(1)
myArray = Application.Transpose(TempArray)
With ActiveSheet.ListObjects("Target_table").Range
.AutoFilter Field:=7, Criteria1:=myArray, Operator:=xlFilterValues
End With
End Sub
When checking array contents with MsgBox, I see the correct values presented, so the correct data seems to be loaded
Code:
MsgBox Join(myArray)
The filtering will work if I hardcode the array, however that's not really useful in this instance:
Code:
.AutoFilter Field:=7, Criteria1:=Array("5,92", "10", "6"), Operator:=xlFilterValues