+ Reply to Thread
Results 1 to 4 of 4

Searching for a string in a multi-lined row

  1. #1
    Registered User
    Join Date
    06-06-2014
    Posts
    2

    Searching for a string in a multi-lined row

    Hi everyone,

    I need suggestions on the best approach for searching for a piece of string from a multi-lined cell. I am trying to do it via VBA but can't seem to figure it out. I tried FIND and Instr.
    I was thinking of converting the muliple lines into a single line then do an instr comparison from the result but I don't know how to do it.

    Sample:

    String to search = "MARY"
    Output Location value

    Table:
    Location-----Names
    US ----------JOHN AND RINGO
    ----------MARTHA YULET

    UK-----------JAMES THE FIRST
    -----------HENRY THE FIFTH
    -----------MARY HAD A LITTLE LAMB
    -----------JOHNNY BRAVO

    Cells in column "Names" has multiple lines
    Cells in column "Location" are not merged

    any help is appreciated. thanks.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Searching for a string in a multi-lined row


    Hi,

    Search into single or multi lines is the same for me ! Easy with Find method !

    So post a sample workbook within your code and an example of the wanted result …

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Searching for a string in a multi-lined row

    To expand, for your situation, Instr would report the character location of the search word. See the example (assuming columns A & B)

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-06-2014
    Posts
    2

    Re: Searching for a string in a multi-lined row

    Thanks both. I went back to my code and tweaked it.
    I stand corrected, FIND function works like a charm.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA for searching string in a column and copy rows depending on string in adjacent cell
    By xprakash in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-20-2013, 05:58 AM
  2. Replies: 4
    Last Post: 10-25-2012, 09:40 PM
  3. Cell Data Header Only Shows Last Line of Multi-lined Cell Data Header
    By Jrub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2012, 05:40 PM
  4. Searching for a string in a cell, and then creating a Sheet for that string
    By vmc62 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2008, 12:07 PM
  5. multi conditional searching
    By realspido in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2006, 04:55 AM

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