Like operator in Excel VBA

Philip

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
user3479671

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Excel VBA like operator

From Dev

Operator Overloading in Excel VBA

From Dev

How to use Like operator in VBA?

From Dev

SQL LIKE in Excel vba

From Dev

using "Not equal" operator in Excel VBA

From Dev

Excel VBA Like Function not working

From Dev

VBA operator "Like" not correctly comparing 2 strings

From Dev

Using Excel's comparison operator in VBA?

From Dev

Excel VBA dict like declaration, initialiazation and accessing

From Dev

Kind of like a reverse pivot in Excel VBA 2007

From Dev

Kind of like a reverse pivot in Excel VBA 2007

From Dev

Excel VBA dict like declaration, initialiazation and accessing

From Dev

&& operator behaves like || operator

From Dev

Excel VBA--Would like to minimize a built-in dialog box

From Dev

Excel VBA: Speed up my Array's Binary like addition

From Dev

Excel VBA--Would like to minimize a built-in dialog box

From Dev

excel vba need date as integer value like in excels datevalue()

From Dev

VLOOKUP-like function: Select case for a long list in VBA Excel

From Dev

Code to Cut a range and paste it on a cell like if it was excel (VBA)

From Dev

Make VBA DateDif behave and round down like Excel DATEDIFF

From Dev

How can I use excel Replace <*> in excel vba like in excel? (regular expressions)

From Dev

Why is it when I enter in an operation in to VBA Excel, VBA removes the operator sign?

From Dev

Why is it when I enter in an operation in to VBA Excel, VBA removes the operator sign?

From Java

Pass an operator like a function

From Dev

Hive - LIKE Operator

From Java

Use of a like operator in dplyr

From Dev

Like operator for integer

From Dev

SQL LIKE operator in datomic

From Dev

Using the -Like operator

Related Related

HotTag

Archive