VBA - 如果找到字符串则为True或False

时间:2014-03-13 08:28:35

标签: excel vba

我试图获得 True False ,具体取决于如果在工作表中找到字符串&# 34; FAL"

Dim stress As Boolean
If fal.UsedRange.Find("Approach = STRESS") > 0 Then
stress = True
Else
stress = False
End If

它给出了"运行时错误' 91':对象变量或者没有设置块"

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

试试这个:

Dim stress As Boolean
stress = Not fal.UsedRange.Find("Approach = STRESS") Is Nothing