PDA

View Full Version : Perform basic operations basen on a cell



Proffskon
10-06-2023, 12:21 AM
Thought this was a simple matter. I want the cell to perform the formula based on what operation is specified in another cell.



2
+
2
4


2
-
2
0


2
/
2
1


2
*
2
4



I want someting like this =A1&B1&C1.
i can get aroung this problem with
=OM(B1="+";A1+C1;OM(B1="-";A1-C1;OM(B1="/";A1/C1;OM(B1="*";A1*C1;))))

Is there any other solution to this?

georgiboy
10-06-2023, 01:45 AM
You can try the below:

In the ribbon go to: Formulas / Name Manager
Click 'New'
Put: EVAL in the 'Name' box
In the 'Refers to' box put: =LAMBDA(x, EVALUATE(x))

Then in your spreadsheet you can use the EVAL function you created as below:

=EVAL(A1&B1&C1)

EDIT: Forgot to mention, this may only work on Excel 365

georgiboy
10-06-2023, 02:52 AM
If you are using an older version of Excel then you could use a small UDF:

Function CalcTextFormula(v1 As String, op As String, v2 As String)
CalcTextFormula = Evaluate(v1 & op & v2)
End Function

Used in the spreadsheet like:

=CalcTextFormula(A1,B1,C1)