答案 0 :(得分:1)
使用Excel的Range.Find
函数,如下所示,执行此检查的IsFound函数。
Function IsFound(ByVal rngRowToSearch As Range, strSearchTerm1 as String, strSearchTerm2 As String) As Boolean
Dim rngFind1 as Range, rngFind2 as Range
' try to find 1st value. If it exists, rngFind1 range will have the address. Else Nothing
rngFind1 = rngRowToSearch.EntireRow.Find(What:=strSearchTerm1, LookIn:=xlValues, MatchCase:=False)
' try to find 2nd value. If it exists, rngFind1 range will have the address. Else Nothing
rngFind2 = rngRowToSearch.EntireRow.Find(What:=strSearchTerm2, LookIn:=xlValues, MatchCase:=False)
IsFound = Not (rngFind1 Is Nothing Or rngFind2 Is Nothing)
End Function
此外,您将按如下方式调用IsFound
函数。
Dim blnFound as Boolean
blnFound = IsFound(Activesheet.Range("A1"),"4AC","04/11/2013")
然后对blnFound