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

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
597
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,224,943
Messages
6,181,921
Members
453,071
Latest member
Gizmo2024

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