+ Reply to Thread
Results 1 to 4 of 4

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

  1. #1
    Shani
    Guest

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

    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


  2. #2
    Bob Phillips
    Guest

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

    If Cells(Rowx, Coly) Like "*cats*" Then

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Shani" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




  3. #3
    John
    Guest

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

    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

    "Shani" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




  4. #4
    Shani
    Guest

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

    thank you


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1