Here's one:
Sub VBAFilterExample()
'Criteria used in search. Change as desired
Const szCRITERIA As String = "rob"
Dim lCount As Long
Dim vOrigArray As Variant
Dim vFilterArray As Variant
Dim szMsgOrig As String, szMsgFilter As String
'Create an array
vOrigArray = Array("Robert", "Rob", "Mac", "Bert", "Sam")
'Store the contents of the array in a string for later use
For lCount = LBound(vOrigArray) To UBound(vOrigArray)
szMsgOrig = szMsgOrig & vOrigArray(lCount) & ", "
Next lCount
'Filter the array based on the criteria. The result is another Array
with just the filtered results
'Note: True = retrieve all that match the criteria. False = retrieve all
that DON'T match the criteria
vFilterArray = Filter(vOrigArray, szCRITERIA, True, vbTextCompare)
'Store the contents of the new filtered array in a string for later use
For lCount = LBound(vFilterArray) To UBound(vFilterArray)
szMsgFilter = szMsgFilter & vFilterArray(lCount) & ", "
Next lCount
'Show the original array, the criteria, and the filtered (resulting)
array in a Message Box
MsgBox "Original Array: " & szMsgOrig & vbLf & vbLf & "Criteria: " &
szCRITERIA & vbLf & vbLf & "Resulting Array: " & szMsgFilter, vbInformation,
"Filter Function Example"
End Sub
_______________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel
"David Robinson" wrote in message
...
can someone post an example of the Filter Function in VB.