'Filter函数(作用于1维数组)
'返回一个下标从零开始的数组,该数组"包含"基于指定筛选条件的一个字符串数组的子集。
'语法
'Filter(要搜索的1维数组。, 搜索的字符串,[TRUE/FALSE])
Sub test()
arr = [{"abc","bb","c","ba","dd","nba"}]
a = Filter(arr, "b", True)
b = Filter(arr, "b", 0)
End Sub
Sub 筛选()
[d2:f999].Clear
i = Cells(Rows.Count, 1).End(xlUp).Row
Range("c2:c" & i).FormulaArray = "=a2:a" & i & " & ""-"" & b2:b" & i
arr = Range("c2:c1" & i)
Range("c2:c1" & i).Clear
a = Filter(Application.Transpose(arr), [g1], True)
For Each b In a
n = n + 1
c = Split(b, "-")
Cells(n + 1, "d") = c(0)
Cells(n + 1, "e") = c(1)
Next
End Sub
|