1

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?

3
  • what string aer you triying to find? Approach = STRESS? Commented Mar 13, 2014 at 8:30
  • Yes, that's a string in a cell. Commented Mar 13, 2014 at 8:31
  • can you post the complete code? 'fal' is the name of your worksheet? have you referenced it in a variable ? Commented Mar 13, 2014 at 8:33

1 Answer 1

3

Try this:

Dim stress As Boolean
stress = Not fal.UsedRange.Find("Approach = STRESS") Is Nothing
Sign up to request clarification or add additional context in comments.

3 Comments

This works perfect! Thanks! I can accept the answer in 5 mins, after I am allowed to.
Actually No... It says that stress = False, when the string is obviously there...
@ViharChervenkov, see my updated answer - you should use stress = Not fal.UsedRange.Find("Approach = STRESS") Is Nothing - note there is Not before fal.UsedRange.Find

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.