Announcement

Collapse
No announcement yet.

Excel 'IF' formulae

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Excel 'IF' formulae

    If (!) anyone could help me out with this problem I'd greatly appreciate it.

    I need to create a formulae where when I input a letter I get a different value out.

    ie - if I put 'a' into a cell A1 then B1 gives a value of 1
    if I input 'b' into A1 then B1 gives a value of 2
    if I input 'c' into A1 then B1 gives a value of 3 etc

    The thing is it needs to have 15 input to output outcomes. In other words up to o=15.

    Using the IF formulae I'm getting bloody confused about where all my brackets go.
    Is there a simpler way to do it?
    Or using the start of my example above can anyone who finds this easy tell me the formulae I'd need?

    Thanks for any help you can give.

    #2
    Is it not if then else if?

    Comment


      #3
      In B1 type:

      =CODE(A1)-96

      That's it

      CODE is a function that returns the ascii value of a letter (a is 97, b is 98 etc.)

      With some error checking looks like:

      =IF((AND((CODE(A1) > 96),CODE(A1) < 112)), CODE(A1)-96,"ERROR")
      Last edited by Brad; 07-10-2013, 20:15.

      Comment


        #4
        You should probably have a second worksheet with the corresponding values then use a vlookup instead. This then allows you to manage dynamic data more effectively, almost like a very basic database.

        Comment


          #5
          Originally posted by FSW View Post
          In B1 type:

          =CODE(A1)-96

          That's it

          CODE is a function that returns the ascii value of a letter (a is 97, b is 98 etc.)

          With some error checking looks like:

          =IF((AND((CODE(A1) > 96),CODE(A1) < 112)), CODE(A1)-96,"ERROR")
          Sorry FSW - it seems I chose a bad example to try to simplify the question!
          My data relates to childrens attainment levels at school.
          Input 'A' would be 1c,1b,1a,2c,2b,2a,3c,3b,3a,4c,4b,4a,5c,5b,5a.
          Depending on which of these I input I would like cell 'B' to score 7,9,11,13,15,17,19,21,23,25,27,29,31,33,35.

          Comment


            #6
            Like I said a VLOOKUP

            In that case you have the second sheet so a table.

            Level Score
            1c 7
            1b 9

            Then on sheet 1 instead of the IF statement

            =VLOOKUP([level_on_sheet_1], [table_on_sheet_2], 2, FALSE)

            =VLOOKUP(value_to_lookup, table of data to match value to, column of data to retrieve value, exact_match?)

            It matches what you input in the column to the second column on the second sheet and returns the value.

            Comment


              #7
              Originally posted by GluedOnBeard View Post
              Like I said a VLOOKUP

              In that case you have the second sheet so a table.

              Level Score
              1c 7
              1b 9

              Then on sheet 1 instead of the IF statement

              =VLOOKUP([level_on_sheet_1], [table_on_sheet_2], 2, FALSE)

              =VLOOKUP(value_to_lookup, table of data to match value to, column of data to retrieve value, exact_match?)

              It matches what you input in the column to the second column on the second sheet and returns the value.
              Cheers buddy! It's worked a treat.
              I was on HowtoGeek looking up your suggestion and inputting it whilst you were typing this one up.
              Thank you so much - my life has just become a lot easier!!

              Comment


                #8
                I use the same method to write my reports...

                Comment


                  #9
                  No worries I only learned about it when I started my current position a couple of years ago, really handy for a lot of tasks.

                  Comment

                  Working...
                  X