Skip to main content

Combining Arithmetic Operators in Excel

 - The basic operators you've just met can be combined to make more complex calculations. For example, you can add to cells together, and multiply by a third one. Like this:
= A1 + A2 * A3
Or this:
= A1 + A2 - A3
And even this:
=SUM(A1:A9) * B1
In the above formula, we're asking Excel to add up the numbers in the cells A1 to A9, and then multiply the answer by B1. You'll get some practise with combining the operators shortly. But there's something you need to be aware of called Operator Precedence.

Operator Precedence

Some of the operators you have just met are calculated before others. This is known as Operator Precedence. As an example, try this:
  • Open a new Excel spreadsheet
  • In cell A1 enter 25
  • In cell A2 enter 50
  • In cell A3 enter 2
Now click in cell A5 and enter the following formula:
=(A1 + A2) * A3
Hit the enter key on your keyboard, and you'll see an answer of 150.
The thing to pay attention to here is the brackets. When you place brackets around cell references, you section these cells off. Excel will then work out the answer to your formula inside of the brackets, A1 + A2 in our formula. Once it has the answer to whatever is inside of your round brackets, it will move on and calculate the rest of your formula. For us, this was multiply by 3. So Excel is doing this:
  • Add up the A1 and A2 in between the round brackets
  • Multiply that answer by A3
Now try this:
  • Click inside A5 where your formula is
  • Now click into the formula bar at the top
  • Delete the two round brackets
  • Hit the enter key on your keyboard
What answer did you get? The images below show the answers with brackets and without:
With Brackets
The answer with brackets

Without Brackets
The answer without brackets
So why did Excel give you two different answers? The reason it did so is because of operator precedence. Excel sees multiplication as more important than adding up, so it does that first. Without the brackets, our formula is this:
A1 + A2 * A3
You and I may work out the answer to that formula from left to right. So we'll add A1 + A2, and THEN multiply by A3. But because Excel sees multiplication as more important, it will do the calculation this way:
  • Multiply A2 by A3 first
  • THEN add the A1
We have 50 in cell A2, and in cell A3 we have the number 2. When you multiply 50 by 2 you get 100. Add the 25 in cell A1 and the answer is 125.
When we used the brackets, we forced Excel to do the addition first:
(A1 + A2) * A3
Add the 25 in cell A1 to the 50 in cell A2 and your get 75. Now multiply by the 2 in cell A3 and you 150.
One answer is not more correct than the other. But because of operator precedence it meant that the multiplication got done first, then the addition. We had to used round brackets to tell Excel what we wanted doing first. Here's another example of operator precedence.
Substitute the asterisk symbol from your formula above with the division symbol. So instead of this:
= (A1 + A2) * A3
the formula will be this:
= (A1 + A2) / A3
When you hit the enter key on your keyboard, you should get an answer of 37.5.
Now click into cell A5, and then click into the formula bar. Delete the two round brackets, and hit the enter key again. What answer did you get this time? Here's the two images:
With the brackets
Operator Precedence in Excel 2007

Without the brackets
Operator Precedence - Without brackets
Just like multiplication, division is seen as more important than addition. So this will get done first. Without the brackets, Excel will first divide A2 by A3. When it has the answer, it will then add the A1. We used the round brackets to force Excel to calculate things differently. Hence the two different answers. One final example.
Change you formula in cell A5 to this:
= (A1 * A2) / A3
Hit the enter key, and you should get an answer of 625.
Again remove the brackets, and hit the enter key. You'll still have an answer of 625. That's because Excel treats multiplication the same as division: they have equal importance. When this happens, Excel will work out the answer from left to right.
Addition and subtraction are also seen as equal to each other. Try this formula in cell A5:
= A1 + A2 - A3
Now put some round brackets in. Try this first:
= (A1 + A2) - A3
And then see what happens when you try this:
= A1 + (A2 - A3)
Was there any difference? There shouldn't have been. You should have the same answer.
So keep Operator Precedence in mind - all sums are not treated equally!

To give you some practice with combination formulas, have a go at constructing the more complex Budget spreadsheet in the link below.

Comments

Popular posts from this blog

Beginners PHP  -This is a complete and free PHP programming course for beginners. It's assumed that you already have some HTML skills. But you don't need to be a guru, by any means. If you need a refresher on HTML, then click the link for the Web Design course on the left of this page. Everything you need to get started with this PHP course is set out in section one below. Good luck! Home Page > PHP Section One - An Introduction to PHP 1. What is PHP and Why do I need it? 2. What you need to get started 3. Installing and testing Wampserver 4. Troubleshooting > PHP Two - Getting Started With Variables 1. What is a Variable? 2. Putting text into variables 3. Variables - some practice 4. More variable practice 5. Joining direct text and variable data 6. Adding up in PHP 7. Subtraction 8. Multiplication 9. Division 10. Floating point numbers > PHP Three - Conditional Logic 1. If Statements 2. Using If Statements 3....
Visual Basic .NET Contents Page   -This computer course is an introduction to Visual Basic.NET programming for beginners. This course assumes that you have no programming experience whatsoever. It's a lot easier than you think, and can be a very rewarding hobby! You don't need to buy any software for this course! You can use the new FREE Visual Basic Express Edition from Microsoft. To see which version you need, click below: Getting the free Visual Studio Express - Which version do I need? > VB .NET One - Getting Started   1. Getting started with VB.NET 2. Visual Basic .NET Forms 3. Adding Controls using the Toolbox Home Page 4. Adding a Textbox to the Form 5. Visual Basic .NET and Properties 6. The Text Property 7. Adding a splash of colour 8. Saving your work 9. Create a New Project >   VB .NET Two - Write your first .NET code   1. What is a Variable? 2. Add a coding button to the Form 3. Writing y...
The Excel SumIF Function  - Another useful Excel function is SumIF. This function is like CountIf, except it adds one more argument: SUMIF( range ,  criteria ,  sum_range ) Range and criteria are the same as with  CountIF  - the range of cells to search, and what you want Excel to look for. The Sum_Range is like range, but it searches a new range of cells. To clarify all that, here's what we'll use SumIF for. (Start a new spreadsheet for this.) Five people have ordered goods from us. Some have paid us, but some haven't. The five people are Elisa, Kelly, Steven, Euan, and Holly. We'll use SumIF to calculate how much in total has been paid to us, and how much is still owed. So in Column A, enter the names: In Column B enter how much each person owes: In Column C, enter TRUE or FALSE values. TRUE means they have paid up, and FALSE means they haven't: Add two more labels: Total Paid, and Still Owed. Your spreadsheet should look something li...