Home > Software engineering >  With excel vba how to implement a single screening of three or more conditions
With excel vba how to implement a single screening of three or more conditions

Time:09-15

Such as company name listed in the filter name contains hangzhou or Beijing or Shanghai or tianjin or in hangzhou

CodePudding user response:

Reference post:
https://bbs.csdn.net/topics/392554132

Function is modified to:
 
Option Explicit

'if strVal string contained within arrKeywords of arbitrary an array of strings, returning True, otherwise it returns False.
The Public Function IsAnyKeywordIncluded (ByVal strVal As String, ParamArray arrKeywords ()) As a Boolean
Dim As Integer I
For I=LBound (arrKeywords) To UBound (arrKeywords)
If InStr (arrKeywords (I), strVal) & gt; 0 Then
IsAnyKeywordIncluded=True
The Exit Function
End the If
Next
IsAnyKeywordIncluded=False
End the Function

Sub Macro3 ()
'
'Macro3 Macro
'

'
Range (" A1: A27). AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range (_
C1, C2), CopyToRange:=Range (I1), Unique:=False
End Sub
  •  Tags:  
  • VBA
  • Related