+ Reply to Thread
Results 1 to 8 of 8

isnumber to parse through words in a sentence

  1. #1
    Registered User
    Join Date
    01-23-2012
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    isnumber to parse through words in a sentence

    I am currently using isnumber to determine whether a specific word exist within a cell that contains a sentence. I am trying to determine how to find the value of a number that always precedes, or follows, a specific word. How can I manipulate the formula, or create a series of formulas, to pull a 'variable word' out that precedes, or follows, a 'constant word'?

    for example,

    There were 39 cats that ran through 45 gates.
    There were 32 cats that ran through 20 gates.

    I am looking to pull the number of cats that ran through gates.


    My current progress...

    The number of cats will always fall between 1 - 100, and the number of gates will also always fall between 1 - 100.
    Currently, I am running 100 columns. Each column has a formula like =ISNUMBER(SEARCH(" 2 cats ",'cell that contains the sentence')), the next column would be =ISNUMBER(SEARCH(" 3 cats ",'cell that contains the sentence')). This returns true or false so that I can have a column that finds the true throughout the rows and returns the cat value of that cell...

    my current problem...
    There are two numbers within each sentence so...I currently have two true columns.


    Question...
    is there a way to pull out the number that precedes the word cats?
    the number of cats will never always be greater than the number of gates nor always less than the number of gates.
    the word 'cats' will remain constant throughout each sentence but the number will change...


    hopefully this is clear enough and someone can help! Thanks in advance!!
    Last edited by bestrella; 01-24-2012 at 12:57 PM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: isnumber to parse through words in a sentence

    bestrella,

    Welcome to the Excel Forum.


    If cell A1 contains:
    There were 39 cats that ran through 45 gates.

    The formula in cell B1:
    =-LOOKUP(1,-RIGHT(TRIM(LEFT(A1,FIND("cats",A1)-1)),{1,2,3,4,5,6}))
    will display 39

    The formula in cell C1:
    =-LOOKUP(1,-RIGHT(TRIM(LEFT(A1,FIND("gates",A1)-1)),{1,2,3,4,5,6}))
    will display 45
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    01-23-2012
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: isnumber to parse through words in a sentence

    Thank you so very much!!! That was exactly the answer I was looking for. Thank you!

  4. #4
    Registered User
    Join Date
    01-23-2012
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: isnumber to parse through words in a sentence

    how would I modify that formula to find the variable that follows the constant rather than precedes it?

  5. #5
    Registered User
    Join Date
    01-23-2012
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: isnumber to parse through words in a sentence

    how would I modify that formula to find the variable that follows the constant rather than precedes it?

  6. #6
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: isnumber to parse through words in a sentence

    bestrella,

    how would I modify that formula to find the variable that follows the constant rather than precedes it?
    I do not know. But, the answer would be one for my archives.

    In the Reply to Thread box, enter just put the word BUMP then click on the Post Quick Reply button, and someone else will assist you.

    Or, create a new Post with another title, say, Find the text/word that immediatley follows a number in a text string.
    Last edited by stanleydgromjr; 01-23-2012 at 06:07 PM.

  7. #7
    Registered User
    Join Date
    01-23-2012
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: isnumber to parse through words in a sentence

    ok, so I did a little research and found that to find a specific value that follows a constant I used the formula

    =MID(A1,(FIND("cats",A1)+6),2)

    Where the 6 is the number of spaces to the right you would like to skip to, and 2 is the number of digits you would like to return. assuming the format of the sentences remains constant, where the number of spaces to the right always stays the same throughout the cells.

  8. #8
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: isnumber to parse through words in a sentence

    bestrella,

    Thanks. This is one for my archives.

  9. #9
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: isnumber to parse through words in a sentence

    Didn't notice this one had been solved.

    Still, my formula is:

    =MATCH(FALSE,INDEX(ISERROR(FIND(" " & ROW(A1:A200) & " cats",A1)),0),0)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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