I have an if statement in a for loop in which I am trying to compare the current Cell value to other strings using the like operator. For some reason this is giving me a type mismatch error. Is this because the rng5.Cells(i, 1).Value
is not a string? Any help would be greatly appreciated! I have pasted the original code below.
For i = 1 To rng5.Rows.Count
If rng5.Cells(i, 1).Value Like "*test*" Or "*Test*" Or "*Demo*" Or "*demo*" Then
rng5.Cells(i, 1).EntireRow.Hidden = True
End If
Next i
use the Instr Function
For i = 1 To rng5.Rows.Count
If instr(1,rng5.Cells(i, 1).Value, "test")>0 Or instr(1,rng5.Cells(i, 1).Value, "Test")>0 Or instr(1,rng5.Cells(i, 1).Value, "demo")>0 Or instr(1,rng5.Cells(i, 1).Value, "Demo")>0 Then
rng5.Cells(i, 1).EntireRow.Hidden = True
End If
Next i
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments