+ Reply to Thread
Results 1 to 4 of 4

Finding a string in another string"

  1. #1
    Forum Contributor
    Join Date
    09-23-2007
    Location
    Melbourne, Australia
    Posts
    176

    Finding a string in another string"

    Hi
    Does anyone know how to find text string in a range of cells.

    I am thinking of using a For each next loop and a If then statement to search for a sring in the words in a range of cells.
    eg For each cell in selection
    If cell.value contains "word" when some cells might containg words like cars, buildings, wording etc I would hope it would find the word "wording" because it contains "word". is there code or a function which can do this?
    Any examples would be great because I don't know how to start this.

    I'm specifically looking for VBA code not excel spreadsheet formula's.

    Thanks.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning danny2000

    What version of Excel are you using? The best thing to use is InStr, but I think it's only available from 2002 onwards. Select a range, at least one of which contains the word "Excel" and run this macro. It will report each occurance and where it was found :

    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Instr is available in Excel 97
    InStrRev is not Available in Excel 97. It was made available in Excel XP or 2000
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi mudraker

    Instr is available in Excel 97
    InStrRev is not Available in Excel 97. It was made available in Excel XP or 2000
    Ahaaa, that's what I was thinking of. Thanks for clearing that up.

    DominicB

+ 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