Filter function
Returns an array of subscripts starting from zero, containing a subset of the string array based on a specific filtering condition.
Filter(InputStrings, Value[, Include[, Compare]])
parameter
InputStrings
Required option. One-dimensional array where you want to search for strings.
Value
Required option. The string to search for.
Include
Optional. Boolean value, specifying whether the returned substring containsValue. ifIncludeforTrue,FilterWill return a substring containingValuesubset of arrays. ifInclude forFalse,FilterWill return no substringValuesubset of arrays.
Compare
Optional. Numeric values indicate the comparison string used type. See the Value Settings section.
set up
CompareThe parameters can have the following values:
constant | value | describe |
---|---|---|
vbBinaryCompare | 0 | Perform binary comparisons. |
vbTextCompare | 1 | Perform text comparison. |
illustrate
IfInputStringsNot found inValueThe matching value,FilterAn empty array will be returned. ifInputStringsforNullOr if it is not a one-dimensional array, an error will occur.
Depend onFilterThe array returned by the function contains only elements that are sufficient to contain the number of matches.
The following example usesFilterThe function returns an array containing the search criteria "Mon":
Dim MyIndexDim MyArray (3)MyArray(0) = "Sunday"MyArray(1) = "Monday"MyArray(2) = "Tuesday"MyIndex = Filter(MyArray, "Mon") 'MyIndex(0)
Include"Monday"
。