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

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
594
Office Version
  1. 365
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 :

[table="width: 500"]
[tr]

[td]3[/td]
[td]*[/td]
[td]5[/td]
[td]=A1&B1&C1[/td]

[/tr]

[/table]


What I want is

[table="width: 500"]
[tr]

[td]3[/td]
[td]*[/td]
[td]5[/td]
[td]15[/td]

[/tr]

[/table]
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
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,223,974
Messages
6,175,739
Members
452,667
Latest member
vanessavalentino83

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