我正在尝试在我的宏中实现包含AND
和OR
函数的搜索函数,在这种情况下使用的正确语句是什么?
如何检测vba中的某些单词?
if input string contains "AND"
{
search for both strings
}
else if input string contains "OR"
{
search for either one
}
else
{
do regular search
}
答案 0 :(得分:0)
这是你在找什么?
Function searchCriteria() As String
Dim str_input As String
str_input = InputBox("Please enter the string")
If str_input <> "" Then
If InStr(1, str_input, "AND", vbTextCompare) Then
searchCriteria = "search for both strings"
ElseIf InStr(1, str_input, "OR", vbTextCompare) Then
searchCriteria = "search for either one"
Else
searchCriteria = "do regular search"
End If
End If
End Function