Calculations over multiple cells

  • Thread starter Thread starter Carl Gilbert
  • Start date Start date
C

Carl Gilbert

I was looking to perform a basic calculation over multiple cells with
the numbers and operators in seperate cells.
For example A1=3, B1=+, C1=4, D1=-, E1=2. I then need to determine the
result based on the operators and numbers given. So the complete
equation when concatenated would be 3+4-2 as given in the example.
So by simple using different operators in the relivant cell, I can
change the calculation without having to re-write the whole thing or
changing any of the other cells.

I hope this makes sense and I would really appreciate it if someone
was able to suggest a solution.
Many thanks, Carl Gilbert.
 
Might be better to create a UDF but this might work

=CHOOSE(MATCH(D1,{"*","+","-","/"},0),CHOOSE(MATCH(B1,{"*","+","-","/"},0),A
1*C1,A1+C1,A1-C1,A1/C1)*E1,CHOOSE(MATCH(B1,{"*","+","-","/"},0),A1*C1,A1+C1,
A1-C1,A1/C1)+E1,CHOOSE(MATCH(B1,{"*","+","-","/"},0),A1*C1,A1+C1,A1-C1,A1/C1
)-E1,CHOOSE(MATCH(B1,{"*","+","-","/"},0),A1*C1,A1+C1,A1-C1,A1/C1)/E1)
 
Back
Top