Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel formula to allow for variable operator 1

Status
Not open for further replies.

murad5

Technical User
Sep 12, 2003
61
0
0
US
Hi,

I'm trying to find a function which will allow me to vary the operator which is used based on a string in another cell

i.e. - formula would be along these lines

=function(A2,B2,C2)

where A2 and B2 are values to which some operator is to be applied and C2 is some string which defines the operation.

So in the case where the values in the cells are 15, 20 and "*" respectively the result would be 15 * 20 = 300, or where the values are 15, 20 and "=" the result would be FALSE.

I guess I could do this by creating a UDF, but I'd rather use inbuilt Excel functionality, if possible.

Any ideas?

Thanks...
 
The only way I can think of is by using nested IFs:

=IF(B1="+",A1+C1,IF(B1="=",A1=C1,......

but you'd probably hit the max of 7 nested functions.

Unless one of the others has any clues, I'd go with the UDF if I were you.

Cheers,

Roel

 
Thanks for the feedback. I'm thinking of trying SUBTOTAL - it would limit me to only a few operators, but hopefully it should be enough to get the app working.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top