+ Reply to Thread
Results 1 to 12 of 12

Find/Mid Formula

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Find/Mid Formula

    Hi,

    I need a formula created that will enable me to find a number within a text and then report the number in another cell.

    Example texts are:

    "unplanned absences (not work related) (8)" and "Working days (YTD) (53)"

    I was thinking of doing a find/mid formula but I am unsure if this would be best and how to do it.

    I would want it to find the number 8 or 53 in the text examples above

    Any suggestions?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434
    Is the number always within the second set of brackets or the last set of brackets?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444
    Hi,

    There are various methods of doing this:

    http://www.excelforum.com/showthread.php?t=630231
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689
    Hi, Thanks for the quick reply.

    The number will always be in the last brackets.

    Some texts only have one set of brackets with the numbers between 1 and four digits long.

    example texts are:
    FTE's at the end of the month (654)
    Leavers (727)
    worked in the month (include everyone) (2)
    Value (1116)

    So using the above I would want the following results if possible:
    654
    727
    2
    1116

    Hope this helps?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434
    Assuming original text in B2 one way would be

    =MID(B2,FIND("^",SUBSTITUTE(B2,"(","^",LEN(B2)-LEN(SUBSTITUTE(B2,"(",""))))+1,FIND("^",SUBSTITUTE(B2,")","^",LEN(B2)-LEN(SUBSTITUTE(B2,"(",""))))-FIND("^",SUBSTITUTE(B2,"(","^",LEN(B2)-LEN(SUBSTITUTE(B2,"(",""))))-1)

  6. #6
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689
    Hi,

    That worked a treat, it done excatley what I wanted it to thanks.

    Is there any way it can return the result as a number though rather than selecting it all, copying it, pasting as a value and then converting it to a number?

    The reason being is i am using a Vlookup and it needs it to be a number.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434
    Wrap the VALUE formula around it

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    you could try
    Please Login or Register  to view this content.

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434
    Hi martin,
    whilst your formula is certainly a lot shorter and easier to understant note that 1 of the first example cases will fail.

    "Working days (YTD) (53)"

  10. #10
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689
    Hi,

    Just wanted to say thanks for your help Andy!! The formula worked Perfectly

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    yep i see that, my fault,humble pie,dindt notice Working days (YTD) (53) from original post!

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Quote Originally Posted by pauldaddyadams
    Some texts only have one set of brackets with the numbers between 1 and four digits long.

    example texts are:
    FTE's at the end of the month (654)
    Leavers (727)
    worked in the month (include everyone) (2)
    Value (1116)
    All these examples have the number in brackets right at the end. If that's always the case try this formula to extract the number when data's in A1

    =LOOKUP(10^4,-RIGHT(A1,{3,4,5,6}))

    This formula should return a number within the last brackets, anywhere in the text....

    =LOOKUP(10^4,MID(A1,LOOKUP(2^15,FIND("(",A1,ROW( INDIRECT("1:"&LEN(A1)))))+1,{1,2,3,4})+0)
    Last edited by daddylonglegs; 05-14-2008 at 06:01 PM.

+ 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