Calculations over multiple cells

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.
 
P

Peo Sjoblom

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top