View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Choosing a Formula Based on a Value

=IF(AND(B2=1,B2=2),A2*5,IF(AND(B2=3,B2=4,B2=5),A2+ 5,A2-5))

--
__________________________________
HTH

Bob

"Rob Fox" <Rob wrote in message
...
How would I choose between several different formulas in a cell based on a
variable in another cell?


Simplified Example:

Let's say I have three fields, field 'A' has a number, field 'B' is our
variable and field 'C' either adds/subtracts or multiplies field 'A' by
5.

How do we get the formula in 'C' to change based on the value in 'B'?
Let's
assume for the moment there are more than 7 different formulas so an
IF/Then
might be tricky.

Is there anyway to do this without a macro?