Trenera
Trenera

Reputation: 1505

VBA - True or False, if string is found

I'm trying to get a True or False, depending on, if a string is found in the worksheet "fal".

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

It gives a "Run-time error '91': Object variable or With block not set"

Any ideas?

Upvotes: 1

Views: 5492

Answers (1)

Dmitry Pavliv
Dmitry Pavliv

Reputation: 35853

Try this:

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

Upvotes: 3

Related Questions