# you can add and subtract dates. Heres very common example ofounting the numb of days betweetwot. Itssimpl=B2-A2Thkey to worki

function adds values. You can add individual values, cell references or ranges or a mix of all three.

=SUM(A2:A10)Adds the values in cells A2:10.

=SUM(A2:A10, C2:C10)Adds the values in cells A2:10, as well as cells C2:C10. The first number you want to add. The number can be like 4, a cell reference like B6, or a cell range like B2:B8. This is the second number you want to add. You can specify up to 255 numbers in this way.

This section will discuss some best practices for working with the SUM function. Much of this can be applied to working with other functions as well.

The =1+2 or =A+B Method While you can enter =1+2+3 or =A1+B1+C2 and get fully accurate results, these methods are error prone for several reasons:

Typos Imagine trying to enter more and/or much larger values like this:

Then try to validate that your entries are correct. Its much easier to put these values in individual cells and use a SUM formula. In addition, you can format the values when theyre in cells, making them much more readable then when theyre in a formula.

VALUE! errors from referencing text instead of numbers

Your formula can break if there are any non-numeric (text) values in the referenced cells, which will return a VALUE! error. SUM will ignore text values and give you the sum of just the numeric values.

REF! error from deleting rows or columns

If you delete a row or column, the formula will not update to exclude the deleted row and it will return a REF! error, where a SUM function will automatically update.

Formulas wont update references when inserting rows or columns

If you insert a row or column, the formula will not update to include the added row, where a SUM function will automatically update (as long as youre not outside of the range referenced in the formula). This is especially important if you expect your formula to update and it doesnt, as it will leave you with incomplete results that you might not catch.

SUM with individual Cell References vs. Ranges

Is equally error prone when inserting or deleting rows within the referenced range for the same reasons. Its much better to use individual ranges, like:

Which will update when adding or deleting rows.

I just want to Add/Subtract/Multiply/Divide numbersSee this video series onBasic Math in Excel, orUse Excel as your calculator.

How do I show more/less decimal places?You can change your number format. Select the cell or range in question and useCtrl+1to bring up theFormat CellsDialog, then click theNumber taband select the format you want, making sure to indicate the number of decimal places you want.

How do I add or subtract Times?You can add and subtract times in a few different ways. For example, to get the difference between 8:00 AM – 12:00 PM for payroll purposes you would use:=(12:00 PM-8:00 AM)*24, taking the end time minus the start time. Note that Excel calculates times as a fraction of a day, so you need to multiply by 24 to get the total hours. In the first example were using=((B2-A2)+(D2-C2))*24to get the sum of hours from start to finish, less a lunch break (8.50 hours total).

If youre simply adding hours and minutes and want to display that way, then you can sum and dont need to multiply by 24, so in the second example were using=SUM(A6:C6)since we just need the total number of hours and minutes for assigned tasks (5:36, or 5 hours, 36 minutes).

How do I get the difference between dates?As with times, you can add and subtract dates. Heres a very common example of counting the number of days between two dates. Its as simple as=B2-A2. The key to working with both Dates and Times is that you start with the End Date/Time and subtract the Start Date/Time.

For more ways to work with dates see:Calculate the difference between two dates.

How do I sum just visible cells?Sometimes, when you manually hide rows or use AutoFilter to display only certain data you also only want to sum the visible cells. You can use theSUBTOTAL function.If youre using a total row in an Excel table, any function you select from the Total drop-down will automatically be entered as a subtotal. See more about how toTotal the data in an Excel table.

You can always ask an expert in theExcel Tech Communityor get support in theAnswers community.

The SUMIF function adds only the values that meet a single criteria

The SUMIFS function adds only the values that meet multiple criteria

The COUNTIF function counts only the values that meet a single criteria

The COUNTIFS function counts only the values that meet multiple criteria