please help Need VBA code that searches for partial text in a cell

  • Thread starter Thread starter Shani
  • Start date Start date
S

Shani

So if a cell contains "catsdogs" i want some code that would return
true

If Cells(Rowx, Coly) = "cat" Then
x = true


This does not work
 
If Cells(Rowx, Coly) Like "*cats*" Then

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Hello Shani,

Use the InStr function as below:

If InStr(1, CStr(Cells(Rowx, Coly).Value), "catsdogs") <> 0 Then
x = True
End If

Best regards

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top