+ Reply to Thread
Results 1 to 9 of 9

Search Text for Value and Display a Value

Hybrid View

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    Stafford
    MS-Off Ver
    Excel 2010
    Posts
    7

    Search Text for Value and Display a Value

    Hi All,

    I have a spread sheet with a series of staff numbers (e.g 11234134), at the end of some of the numbers, there can be either -2, -3, -4, -5, -6 (e.g. 1123134-3)

    I want to create a formula which will look at the number and if the number has -2 return 'Leave 2' if not 'Leave 1', or if it is -3 return 'Leave 3' if not 'Leave 1' and so on, except for -6, i want it to return 'Leave 1'

    Could any one advise how i could go about this?

    Thanks,

    Luke.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    964

    Re: Search Text for Value and Display a Value

    try this (replace O14 for your cell though

    =IF(RIGHT($O$14,1)<>6,"Leave "&RIGHT($O$14,1),"Leave 1")
    i think that this will work
    The Importance of INDEX - A GUIDE TO INDEX'S OTHER USES
    <--- If a post helps hit the star

  3. #3
    Registered User
    Join Date
    10-11-2012
    Location
    Stafford
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Search Text for Value and Display a Value

    Thanks for the reply. Unfortunately it doesn't seem to do what i need.

    I need the formula to return a different value depending on the number. So if the number ends in -4, return 'Leave 4', if it ends in -2, return 'Leave 2'. If the number does not contain a '-' then return 'Leave 1'

    Thanks again for your help

  4. #4
    Registered User
    Join Date
    09-02-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Search Text for Value and Display a Value

    hi

    i took a shot at what you might be looking for

    =IF(RIGHT(D7,2)="-6","Leave 1",REPLACE(D7,1,8,"Leave "))
    Last edited by Hyperdude; 10-11-2012 at 11:15 PM.
    Regards,
    Hyperdude

  5. #5
    Registered User
    Join Date
    10-11-2012
    Location
    Stafford
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Search Text for Value and Display a Value

    Sample.xlsx

    Thanks once again for another reply, but this doesn't quite fill all the requirements.
    I've attached a sample of what i need the formula for.
    Depending on the number, the Leave type will be different.
    I've tried what i can, but nothing seems to be able to do it.

    Really stuck with this one.

    Appreciate any help.

  6. #6
    Registered User
    Join Date
    10-11-2012
    Location
    Stafford
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Search Text for Value and Display a Value

    Anyone know a way to do this?

  7. #7
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: Search Text for Value and Display a Value

    Try,

    =IF(OR(MID(A2,LEN(A2)-1,1)<>"-",RIGHT(A2)="6"),"Leave 1 Owe","Leave "&RIGHT(A2)+1&" Owe")

    Works on your sample file.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Search Text for Value and Display a Value

    Your sample file doesn't conform to your explanation in your original post.
    You said in Post #1 that if number ends in -2 then you want "Leave 2" returned
    But your sample file shows that you want "Leave 3 Owe" returned.

    Assuming your original explanation is what you want (regarding the numeric return) then this is an option:

    ="Leave "&IF(AND(RIGHT(A2,2)*1<-1,RIGHT(A2,2)*1>-6),RIGHT(A2),1)&" Owe"

  9. #9
    Registered User
    Join Date
    10-11-2012
    Location
    Stafford
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Search Text for Value and Display a Value

    Thanks for that guys, both of them work. Sorry for any confusion, my sample was incorrect.

    Haseeb, would you be able to give me a break down of how your formula works. Will help me in the future if I know how it works.

    Genuine thanks to you all, been a great help.

+ 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