Function Filter2DArray(ByVal sArray, ByVal ColIndex As Long, ByVal FindStr As String, ByVal HasTitle As Boolean)
Dim TmpArr, I As Long, J As Long, Arr, Dic, TmpStr, Tmp, Chk As Boolean, TmpVal As Double
On Error Resume Next
Set Dic = CreateObject("Scripting.Dictionary")
TmpArr = sArray
ColIndex = ColIndex + LBound(TmpArr, 2) - 1
Chk = (InStr("><=", Left(FindStr, 1)) > 0)
For I = LBound(TmpArr, 1) - HasTitle To UBound(TmpArr, 1)
If Chk And FindStr <> "" Then
TmpVal = CDbl(TmpArr(I, ColIndex))
If Evaluate(TmpVal & FindStr) Then Dic.Add I, ""
Else
If Left(FindStr, 1) = "!" Then
If Not (UCase(TmpArr(I, ColIndex)) Like UCase(Mid(FindStr, 2, Len(FindStr)))) Then Dic.Add I, ""
Else
If UCase(TmpArr(I, ColIndex)) Like UCase(FindStr) Then Dic.Add I, ""
End If
End If
Next
If Dic.Count > 0 Then
Tmp = Dic.Keys
ReDim Arr(LBound(TmpArr, 1) To UBound(Tmp) + LBound(TmpArr, 1) - HasTitle, LBound(TmpArr, 2) To UBound(TmpArr, 2))
For I = LBound(TmpArr, 1) - HasTitle To UBound(Tmp) + LBound(TmpArr, 1) - HasTitle
For J = LBound(TmpArr, 2) To UBound(TmpArr, 2)
Arr(I, J) = TmpArr(Tmp(I - LBound(TmpArr, 1) + HasTitle), J)
Next
Next
If HasTitle Then
For J = LBound(TmpArr, 2) To UBound(TmpArr, 2)
Arr(LBound(TmpArr, 1), J) = TmpArr(LBound(TmpArr, 1), J)
Next
End If
End If
Filter2DArray = Arr
End Function