0

I have a simple if statement using the In String function referencing a collection and cell within my worksheet.

    If Not InStr(1, MyPeople(n).DivisionOwner, cel.Offset(0, 12).Value, 1) Then
        cel.EntireRow.Hidden = True
    End If

The problem is that I know for a fact that i am referencing the correct cell and collection cell. I even tested it with a simple MsgBox(MyPeople(n).DivisionOwner)

This means the problem must be in my statement, but it's simply not working!

enter image description here

enter image description here

3
  • I think it should be Cells. not cel. Commented Jul 24, 2017 at 17:28
  • Public cel As Range, rng As Range is part of my public variables Commented Jul 24, 2017 at 17:29
  • Well then never mind! Commented Jul 24, 2017 at 17:29

1 Answer 1

1

Try :

If InStr(1, MyPeople(n).DivisionOwner, cel.Offset(0, 12).Value, 1) = 0 Then

Assuming cel is defined as Range.

Sign up to request clarification or add additional context in comments.

3 Comments

yup Public cel As Range, rng As Range. checking
Just checked. Works fine, just needs 1 instead of zero, thank you!
@CodingNovice you wanted to check if the Instr doesn't find a match, right ?

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.