Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Excel 2003 - IF statement problem

  • 04-11-2009 07:24PM
    #1
    Closed Accounts Posts: 79 ✭✭


    Hi,

    Basicially I'm trying to work out an IF statement to work out whether someone is over 21 or not. I want it to say "Yes" if true and "No" if false. My problem is that the cell where their age is located was used in another calculation so it reads:

    =DATEDIF($C2,$B$21,"y") & " years "

    rather than F2.

    If I use F2 in the formula it tells me that the person is over 21 but their age is actually 20 (Cell F2 appears as "20 years").

    If anyone can help I would greatly appreciate it. If you need me to clarify anything either, just let me know!


Comments

  • Registered Users, Registered Users 2 Posts: 3,091 ✭✭✭Antar Bolaeisk


    To extract the number from the cell insert into your if loop Value(Left(F2,2))

    eg =if(value(left(f2,2)<21,"No","Yes")

    What this will do is extract the first two characters from the left of the string in cell F2, in otherwords the number you are looking for, and then convert it into an integer for use in the if statement. Not sure if this will fail if there is only a 1 character year in F2 though.

    Of course the easiest way to do this would be to have a secondary cell where only the age without "years" is used and just hide it.


  • Closed Accounts Posts: 79 ✭✭sinn7


    Thank you so much, I have it working now :D
    I spent so long just staring at that screen...


Advertisement