Option explicit ' actual function Public function filter2dArray(a, text) Dim i For i = ubound(a) to lbound(a) step -1 If instr(join(a(i), vbTab), text) = 0 Then ' no match. switch it with ubound and delete ubound a(i) = a(ubound(a)) ReDim preserve a(ubound(a)-1) End If Next filter2dArray = a End Function ' test code Dim b, i b = array( array("row1", "monday", "work"), _ array("row2", "tuesday", "work"), _ array("row3", "wednesday", "free")) b = filter2dArray(b, "work") For i = lbound(b) to ubound(b) msgbox i & ": " & join(b(i), vbTab) Next
As you requested: filter function for 2D arrays.
Limitations: it only works with text 2d arrays, and it does not have an Include and Compare switch, but it is not difficult.
source share