"CASE" function in Excel

Solved
pleduc Posted messages 8 Registration date   Status Member -  
BmV Posted messages 43659 Registration date   Status Moderator Last intervention   -
Hello,

I would like to use a function like "CASE" in Excel instead of nesting "IF" functions within each other. My goal is to perform the following test:

If Cell A1 = Cell B1 then ...
If Cell A1 = Cell B2 then ...
If Cell A1 = Cell B3 then ...
If Cell A1 = Cell B4 then ...
If Cell A1 = Cell B5 then ...
If Cell A1 = Cell B6 then ...
...

Thank you in advance
Configuration: Windows 2003 Internet Explorer 6.0

4 answers

  1. Ivan-hoe Posted messages 433 Registration date   Status Member Last intervention   310
     
    Hello to both of you,
    Pleduc, as far as I know, the CASE you’re talking about, which advantageously replaces IF functions, is a VBA Excel instruction and is not used directly in Excel formulas.
    In which case, the syntax is as follows:

    Select Case Range("A1").Value Case Is = Range("B1").Value 'instructions Case Is = Range("B2").Value 'instructions Case Else 'instructions in case none of the conditions are met End Select
    18
    1. pleduc Posted messages 8 Registration date   Status Member 1
       
      Hello,

      Thank you very much, it works!
      0
    2. anonyme
       
      The function =CHOOSE exists. For more information, refer to Excel's help
      It works very well.
      =CHOOSE(index; Val1, Val2....)
      index: is the cell to evaluate
      Val1: is the value returned if the index cell is equal to 1
      Val2: is the value returned if the index cell is equal to 2 ...
      2
      1. touroul Posted messages 520 Registration date   Status Member Last intervention   16 > anonyme
         

        Hello

        It's crazy what you can learn by browsing this forum.

        I thought AI would kill it, but I'm coming back to it.

        AIs are often bad for Excel.

        Thanks to those who give their time, without expecting anything in return other than gratitude.

        We'll never say it enough.

        Finally, something where money has no place.

        0