Coding Novice
Coding Novice

Reputation: 447

VBA-Excel If Not In String Returning False When Should Be True

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

Upvotes: 0

Views: 303

Answers (1)

Shai Rado
Shai Rado

Reputation: 33682

Try :

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

Assuming cel is defined as Range.

Upvotes: 1

Related Questions