Return maths anser whereby numbers in A and C and symbol in B

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
579
Office Version
  1. 2016
Is it possible to have Excel do an equation whereby, in Column A you have a number, Column B you have a +, -, *, / etc and in Column C you have another number. I have tried a simple =A1&B1&C1 etc but this only pastes as texts and does not pick it up as if you entered that into a cell
So I have :

3*5=A1&B1&C1


What I want is

3*515
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You can do it easily with a UDF but not sure you can as you wrote.

Code:
Function maths(first As Range, symbol As Range, last As Range)

Select Case symbol
    Case "+"
        maths = first + last
    Case "-"
        maths = first - last
    Case "*"
        maths = first * last
    Case "/"
        maths = first / last
    Case Else
        maths = CVErr(xlErrNA)
End Select
    
End Function

Then on the worksheet you can do:

=maths(A1,B1,C1)

edit you can write it a bit shorter like this:

Code:
Function maths(first As Range, symbol As Range, last As Range)

Select Case symbol
    Case "+", "-", "*", "/"
        maths = Evaluate(first & symbol & last)
    Case Else
        maths = CVErr(xlErrNA)
End Select
    
End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,170
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top