Automate calculations

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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)
 

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

Back
Top