Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Excel 2003 - IF statement problem

Options
  • 04-11-2009 7: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 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