"CASE" function in Excel

Solved
pleduc Posted messages 8 Registration date   Status Membre -  
 anonyme -
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

2 answers

Ivan-hoe Posted messages 433 Registration date   Status Member Last intervention   309
 
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
17
pleduc Posted messages 8 Registration date   Status Member 1
 
Hello,

Thank you very much, it works!
0
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 ...
0