ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automate calculations (https://www.excelbanter.com/excel-programming/319313-automate-calculations.html)

Cheryl

Automate calculations
 
How can automate a calculation in the following scenario:
Eg.
Column 1 = A
Column 2 = Maths operation eg. + / - / X / ./.
Column 3 = B
To automate calculation in column 4 = A + or - or X or ./. B depending on
what is keyed into column 2
Thank you in advance

Frank Kabel

Automate calculations
 
Hi
try the following UDF:
Public Function my_calculate(op1 As Range, operand As Range, op2 As Range)
my_calculate = Application.Evaluate("=" & op1.Value & operand.Value &
op2.Value)
End Function

And now use in your spreadsheet in D1:
=my_calculate(A1,B1,C1)


--
Regards
Frank Kabel
Frankfurt, Germany
"Cheryl" schrieb im Newsbeitrag
...
How can automate a calculation in the following scenario:
Eg.
Column 1 = A
Column 2 = Maths operation eg. + / - / X / ./.
Column 3 = B
To automate calculation in column 4 = A + or - or X or ./. B depending on
what is keyed into column 2
Thank you in advance





All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com