# Select a category

# How To Use Formulas And Functions In Excel

4 years ago

~14.3 mins read

Learning how to use functions in Excel is very helpful. They are the basic guts of the formulas. If you want to see a listing of the functions to get an idea of what is available, click on the “Insert” menu/group and then at the far left, choose “Function/Functions.”

Even though the purpose of this button in the Excel Ribbon is to insert an actual function (which can also be accomplished by typing in the formula bar, starting with an equals sign and then starting to type the desired function), we can also use this to see what is available. You can scroll through the functions to get a sort of idea of what you can use in your formulas.

Granted, it is also very helpful to simply try them out and see what they do. You can select the group that you want to peruse by choosing a category, like “Commonly Used” for a shorter list of functions but a list that is often used (and for which some functions are covered in this article).

We will be using some of these functions in the examples of the formulas we discuss in this article.

So just remember that before you are asking Excel to calculate or automate anything for you, that you type an equals sign ( = ) in the cell.

If you include a $ sign, that tells Excel not to move the formula. Normally, the auto adjustment of formulas (using what is called relative cell references), to changes in the worksheet, is a helpful thing but sometimes you may not want it and with that $ sign, you are able to tell Excel that. You simply insert the $ in front of the letter and number of the cell reference.

So a relative cell reference of D25 becomes $D$25. If this part is confusing, don’t worry about it. You can come back to it (or play with it with an Excel blank workbook).

Let’s try it in an Excel Worksheet. For this example, let’s use a blank sheet so we don’t interrupt any other project. Go ahead and type your first name in A1 and type your last name in B1.

Now, to combine them, click your mouse on the C1 cell and type this formula: =A1 & “ “ & B1. Please only use the part in italics and not any of the rest of it (like not using the period).

What do you see in C1? You should see your full name complete with a space between your first and last names, as would be normal in typing your full name. The & “ “ & portion of the formula is what produced that space. If you had not included “ “ you would have had your first name and last name without a space between them (go ahead and try it if you want to see the result).

Another similar formula uses CONCAT but we will learn about that a little later. For now, keep in mind what the ampersand ( & ) can do for you as this little tip comes in handy in many situations.

We started by typing in some numbers so we had some data to work with in the use of the function. We simply used 1, 2, 3, 4, 5 and started in A1 and typed in each cell going downward toward A5.

Now, to use the SUM() function, start by clicking in the desired cell, in this case we used A6, and typing =SUM( in the formula bar. In this example, stop when you get to the first “(.” Now, click in A1 (the top-most cell) and drag your mouse to A5 (or the bottom-most cell you want to include) and then return to the formula bar and type the closing “).” Do not include the periods or quotation marks and just the parentheses.

The other way to use this function is to manually type the information in the formula bar. This is especially helpful if you have quite a few numbers and scrolling to grab them is a bit difficult. Start this method the same way that you did for the example above, with “=SUM(.”

Then, type the top-most cell’s cell reference. In this case, that would be A1. Include a colon ( : ) and then type the bottom-most cell’s cell reference. In this case, that would be A5.

What if you wanted to figure out what the average of a group of numbers was? You can easily do that with the AVERAGE() function. You will notice, in the steps below, that it is basically the same as the SUM() function above but with a different function.

With that in mind, we start by selecting the cell we want to use for the result (in this case A6) and then start typing with an equals sign ( = ) and the word AVERAGE. You will notice that as you begin typing it you are offered suggestions and can click on AVERAGE instead of typing the full word, if you like.

Ensure that you have an opening parenthesis in your formula before we add our cell range.

Otherwise, you will receive an error.

Now that we have “=AVERAGE(“ typed in our A6 cell (or whichever cell you are using for the result) we can select the cell range that we want to use. In this case we are using A1 through A5.

Keep in mind that you can also type it in manually rather than using the mouse to select the range. If you have a large data set typing in the range is probably easier than the scrolling that would be required to select it. But, of course, it is up to you.

To complete the process simply type in the closing parenthesis “)” and you will receive the average of the five numbers. As you can see, this process is very similar to the SUM() process and other functions. Once you get the hang of one function, the others will be easier.

Now, in A11 let’s start our function/formula. In this case, we are going to type “=COUNTIF(.” Then, we will select cells A1 through A10.

Be sure that you type or select “COUNTIF” and not one of the other COUNT-like functions or we will not get the same result.

Before we do like we have with our other functions, and type the closing parenthesis “)” we need to answer the question of criteria and type that, after a comma “,” and before the parenthesis “).”

What is defined by the “criteria?” That is where we tell Excel what we want it to count (in this case). We typed a comma and then a “5” and then the closing parenthesis to obtain the count of the number of fives (5) that appear in the list of numbers. That result would be two (2) as there are two occurrences.

Type your first name in A1 and your last name in B1. Then, in C1 type CONCAT(A1, “ “ , B1).

You will see that you get the same result as we did with the ampersand (&). Many people use the ampersand because it is easier and less cumbersome but now you see that you also have another option.

Note: This function may be CONCANTENATE in your version of Excel. Microsoft shortened the function name to just CONCAT and that tends to be easier to type (and remember) in the later versions of the software. Fortunately, if you start typing CONCA in your formula bar (after the equals sign), you will see which version your version of Excel uses and can select it by clicking on it with the mouse..

Remember that when you start to type it, to allow your version of Excel to reveal the correct function, to only type “CONCA” (or shorter) and not “CONCAN” (as the start for CONCANTENATE) or you may not see Excel’s suggestion since that is where the two functions start to differ.

Don’t be surprised if you prefer to use the merge method with the ampersand (&) instead of CONCAT(). That is normal.

Now, we type in the formula. In this case, we type it in F2 and it is “=IF(E2>25000, “DISCOUNT 2”). This fulfills what the formula is looking for with a test (E2 greater than 25k) and then a result if the number in E2 passes that test (“DISCOUNT 2”).

Now, copy F2 and paste in the cells that follow it in the F column.

The formula will automatically adjust for each cell (relative cell referencing), with a reference to the appropriate cell. Remember that if you do not want it to automatically adjust, you can precede the cell alpha with a $ sign as well as the number, like A1 is $A$1.

You can see, in the image above, that “DISCOUNT 2” appears in all of the cells in the F2 column. This is because the formula tells it to look at the E2 cell (represented by $E$2) and no relative cells. So, when the formula is copied to the next cell (i.e. F3) it is still looking at the E2 cell because of the dollar signs. So, all of the cells give the same result because they have the same formula referencing the same cell.

Also, if you want a value to show up instead of the word, “FALSE,” simply add a comma and then the word or number that you want to appear (text should be in quotes) at the end of the formula, before the ending parenthesis.

If you have an Excel sheet with a lot of dates, chances are you will eventually need to calculate the differences between some of those dates. Maybe you want to see how many months it took you to pay off your debt or how many days it took you to lose a certain amount of weight?

Calculating the difference between dates in Excel is easy, but can become complicated depending on how you want to calculate certain values. For example, if you wanted to know the number of months between 2/5/2016 and 1/15/2016, should the answer be 0 or 1? Some people might say 0 since it’s not a full month between the dates and others might say 1 because it’s a different month.

In this article, I’ll show you how to calculate the differences between two dates to find the number of days, months and years with different formulas, depending on your preferences.

In my example above, I have two dates stored in cells A2 and A3.

At the right, you can see the difference between those two dates is 802 days. In Excel, there are always multiple ways to calculate the same value and that’s what I did here. Let’s take a look at the formulas:

The first formula is just a simple subtraction of the two dates, A3 – A2. Excel knows it’s a date and simply calculates the number of days between those two dates. Easy and very straight-forward. In addition, you can also use the DAYS function.

=DAYS(A3, A2)

This function takes two arguments: the end date and the start date.

If you switch the dates in the formula, you’ll just get a negative number. Lastly, you can use a function called DATEDIF, which is included in Excel from Lotus 1-2-3 days, but isn’t an officially supported formula in Excel.

=DATEDIF(A2, A3, "D")

When you type the formula, you’ll see that Excel does not give you any suggestions for the fields, etc. Luckily, you can see the syntax and all supported arguments for the DATEDIF function here.

As an added bonus, what if you wanted to calculate the number of weekdays between two dates? That’s easy enough also because we have a built-in formula:

=NETWORKDAYS(startDate,endDate)

Calculating the number of days and weekdays is simple enough, so let’s talk about months now.

Since that is kind of pointless, let’s look at some formulas that will get us the correct answer. Microsoft has provided these here, but if you are too lazy to visit the link, I have provided them below also.

Round Up - =(YEAR(LDate)-YEAR(EDate))*12+MONTH(LDate)-MONTH(EDate)

Round Down - =IF(DAY(LDate)>=DAY(EDate),0,-1)+(YEAR(LDate)-YEAR(EDate))

*12+MONTH(LDate)-MONTH(EDate)

Now these are two fairly long and complicated formulas and you really don’t need to understand what’s going on.

Here are the formulas in Excel:

Note the you should edit the round down formula in the actual cell itself because for some odd reason the entire formula does not show up in the formula bar. In order to see the formula in the cell itself, click on the Formulas tab and then click Show Formulas.

So what’s the final result of the two formulas on our current example? Let’s see below:

Round up gives me 27 months and round down gives me 26 months, which is accurate, depending on how you want to look at it. Lastly, you can also use the DATEDIF function, but it only calculates full months, so in our case the answer it returns is 26.

=DATEDIF(A2, A3, "M")

One formula uses DATEDIF and the other uses the YEAR function. Since the difference in the number of days is only 802, DATEDIF shows 2 years whereas the YEAR function shows 3 years.

Again, this is a matter of preference and depends on what exactly you are trying to calculate. It’s a good idea to know both methods so that you can attack different problems with different formulas.

As long as you are careful with which formulas you use, it’s fairly easy to calculate exactly what you are looking for.

There are also a lot more date functions outside of the ones I mentioned, so feel free to check those out also on the Office Support site. If you have any questions, feel free to comment. Enjoy!

Author: Aseem Kishore

.

";

Even though the purpose of this button in the Excel Ribbon is to insert an actual function (which can also be accomplished by typing in the formula bar, starting with an equals sign and then starting to type the desired function), we can also use this to see what is available. You can scroll through the functions to get a sort of idea of what you can use in your formulas.

Granted, it is also very helpful to simply try them out and see what they do. You can select the group that you want to peruse by choosing a category, like “Commonly Used” for a shorter list of functions but a list that is often used (and for which some functions are covered in this article).

We will be using some of these functions in the examples of the formulas we discuss in this article.

## The Equals = Sign

The equals sign ( = ) is very important in Excel. It plays an essential role. This is especially true in the cases of formulas. Basically, you don’t have a formula without preceding it with an equals sign. And without the formula, it is simply the data (or text) you have entered in that cell.So just remember that before you are asking Excel to calculate or automate anything for you, that you type an equals sign ( = ) in the cell.

If you include a $ sign, that tells Excel not to move the formula. Normally, the auto adjustment of formulas (using what is called relative cell references), to changes in the worksheet, is a helpful thing but sometimes you may not want it and with that $ sign, you are able to tell Excel that. You simply insert the $ in front of the letter and number of the cell reference.

So a relative cell reference of D25 becomes $D$25. If this part is confusing, don’t worry about it. You can come back to it (or play with it with an Excel blank workbook).

## The Awesome Ampersand >> &

The ampersand ( & ) is a fun little formula “tool,” allowing you to combine cells. For example, let’s say that you have a column for first names and another column for last names and you want to create a column for the full name. You can use the & to do just that.Let’s try it in an Excel Worksheet. For this example, let’s use a blank sheet so we don’t interrupt any other project. Go ahead and type your first name in A1 and type your last name in B1.

Advertisement

What do you see in C1? You should see your full name complete with a space between your first and last names, as would be normal in typing your full name. The & “ “ & portion of the formula is what produced that space. If you had not included “ “ you would have had your first name and last name without a space between them (go ahead and try it if you want to see the result).

Another similar formula uses CONCAT but we will learn about that a little later. For now, keep in mind what the ampersand ( & ) can do for you as this little tip comes in handy in many situations.

## SUM() Function

The SUM() function is very handy and it does just what it describes. It adds up the numbers you tell Excel to include and gives you the sum of their values. You can do this in a couple of different ways.We started by typing in some numbers so we had some data to work with in the use of the function. We simply used 1, 2, 3, 4, 5 and started in A1 and typed in each cell going downward toward A5.

Now, to use the SUM() function, start by clicking in the desired cell, in this case we used A6, and typing =SUM( in the formula bar. In this example, stop when you get to the first “(.” Now, click in A1 (the top-most cell) and drag your mouse to A5 (or the bottom-most cell you want to include) and then return to the formula bar and type the closing “).” Do not include the periods or quotation marks and just the parentheses.

The other way to use this function is to manually type the information in the formula bar. This is especially helpful if you have quite a few numbers and scrolling to grab them is a bit difficult. Start this method the same way that you did for the example above, with “=SUM(.”

Then, type the top-most cell’s cell reference. In this case, that would be A1. Include a colon ( : ) and then type the bottom-most cell’s cell reference. In this case, that would be A5.

AVERAGE() Function

What if you wanted to figure out what the average of a group of numbers was? You can easily do that with the AVERAGE() function. You will notice, in the steps below, that it is basically the same as the SUM() function above but with a different function. With that in mind, we start by selecting the cell we want to use for the result (in this case A6) and then start typing with an equals sign ( = ) and the word AVERAGE. You will notice that as you begin typing it you are offered suggestions and can click on AVERAGE instead of typing the full word, if you like.

Ensure that you have an opening parenthesis in your formula before we add our cell range.

Advertisement

Now that we have “=AVERAGE(“ typed in our A6 cell (or whichever cell you are using for the result) we can select the cell range that we want to use. In this case we are using A1 through A5.

Keep in mind that you can also type it in manually rather than using the mouse to select the range. If you have a large data set typing in the range is probably easier than the scrolling that would be required to select it. But, of course, it is up to you.

To complete the process simply type in the closing parenthesis “)” and you will receive the average of the five numbers. As you can see, this process is very similar to the SUM() process and other functions. Once you get the hang of one function, the others will be easier.

## COUNTIF() Function

Let’s say we wanted to count how many times a certain number shows up in a data set. First, let’s prepare our file for this function so that we have something to count. Remove any formula that you may have in A6. Now, either copy A1 through A5 and paste starting in A6 or simply type the same numbers in the cells going downward starting with A6 and the value of 1 and then A7 with 2, etc.Now, in A11 let’s start our function/formula. In this case, we are going to type “=COUNTIF(.” Then, we will select cells A1 through A10.

Be sure that you type or select “COUNTIF” and not one of the other COUNT-like functions or we will not get the same result.

Before we do like we have with our other functions, and type the closing parenthesis “)” we need to answer the question of criteria and type that, after a comma “,” and before the parenthesis “).”

What is defined by the “criteria?” That is where we tell Excel what we want it to count (in this case). We typed a comma and then a “5” and then the closing parenthesis to obtain the count of the number of fives (5) that appear in the list of numbers. That result would be two (2) as there are two occurrences.

## CONCAT or CONCANTENATE() Function

Similar to our example using just the ampersand ( & ) in our formula, you can combine cells using the CONCAT() function. Go ahead and try it, using our same example.Type your first name in A1 and your last name in B1. Then, in C1 type CONCAT(A1, “ “ , B1).

You will see that you get the same result as we did with the ampersand (&). Many people use the ampersand because it is easier and less cumbersome but now you see that you also have another option.

Note: This function may be CONCANTENATE in your version of Excel. Microsoft shortened the function name to just CONCAT and that tends to be easier to type (and remember) in the later versions of the software. Fortunately, if you start typing CONCA in your formula bar (after the equals sign), you will see which version your version of Excel uses and can select it by clicking on it with the mouse..

Remember that when you start to type it, to allow your version of Excel to reveal the correct function, to only type “CONCA” (or shorter) and not “CONCAN” (as the start for CONCANTENATE) or you may not see Excel’s suggestion since that is where the two functions start to differ.

Don’t be surprised if you prefer to use the merge method with the ampersand (&) instead of CONCAT(). That is normal.

## If/Then Formulas

Let’s say we want to use an If/Then Formula to identify Discount (sort of a second discount) amount in a new column in our Example Excel file. In that case, first we start by adding a column and we are adding it after Column F and before Column G (again, in our downloaded example file).Now, we type in the formula. In this case, we type it in F2 and it is “=IF(E2>25000, “DISCOUNT 2”). This fulfills what the formula is looking for with a test (E2 greater than 25k) and then a result if the number in E2 passes that test (“DISCOUNT 2”).

Now, copy F2 and paste in the cells that follow it in the F column.

The formula will automatically adjust for each cell (relative cell referencing), with a reference to the appropriate cell. Remember that if you do not want it to automatically adjust, you can precede the cell alpha with a $ sign as well as the number, like A1 is $A$1.

You can see, in the image above, that “DISCOUNT 2” appears in all of the cells in the F2 column. This is because the formula tells it to look at the E2 cell (represented by $E$2) and no relative cells. So, when the formula is copied to the next cell (i.e. F3) it is still looking at the E2 cell because of the dollar signs. So, all of the cells give the same result because they have the same formula referencing the same cell.

Also, if you want a value to show up instead of the word, “FALSE,” simply add a comma and then the word or number that you want to appear (text should be in quotes) at the end of the formula, before the ending parenthesis.

# Example of how to use Excel function and formulas to subtract dates in Excel

If you have an Excel sheet with a lot of dates, chances are you will eventually need to calculate the differences between some of those dates. Maybe you want to see how many months it took you to pay off your debt or how many days it took you to lose a certain amount of weight?

Calculating the difference between dates in Excel is easy, but can become complicated depending on how you want to calculate certain values. For example, if you wanted to know the number of months between 2/5/2016 and 1/15/2016, should the answer be 0 or 1? Some people might say 0 since it’s not a full month between the dates and others might say 1 because it’s a different month.

In this article, I’ll show you how to calculate the differences between two dates to find the number of days, months and years with different formulas, depending on your preferences.

## Days Between Two Dates

The simplest calculation we can do is to get the number of days between two dates. The good thing about calculating days is that there really is only one way to calculate the value, so you don’t have to worry about different formulas giving you different answers.In my example above, I have two dates stored in cells A2 and A3.

Advertisement

The first formula is just a simple subtraction of the two dates, A3 – A2. Excel knows it’s a date and simply calculates the number of days between those two dates. Easy and very straight-forward. In addition, you can also use the DAYS function.

=DAYS(A3, A2)

This function takes two arguments: the end date and the start date.

Advertisement

=DATEDIF(A2, A3, "D")

When you type the formula, you’ll see that Excel does not give you any suggestions for the fields, etc. Luckily, you can see the syntax and all supported arguments for the DATEDIF function here.

As an added bonus, what if you wanted to calculate the number of weekdays between two dates? That’s easy enough also because we have a built-in formula:

=NETWORKDAYS(startDate,endDate)

Calculating the number of days and weekdays is simple enough, so let’s talk about months now.

## Months Between Two Dates

The trickiest calculation is the number of months because of how you can either round up or round down depending on whether it’s a complete month or a partial month. Now there is a MONTHS function in Excel, but it’s very limited because it will only look at the month when calculating the difference and not the year. This means it’s only useful for calculating the difference between two months in the same year.Since that is kind of pointless, let’s look at some formulas that will get us the correct answer. Microsoft has provided these here, but if you are too lazy to visit the link, I have provided them below also.

Round Up - =(YEAR(LDate)-YEAR(EDate))*12+MONTH(LDate)-MONTH(EDate)

Round Down - =IF(DAY(LDate)>=DAY(EDate),0,-1)+(YEAR(LDate)-YEAR(EDate))

*12+MONTH(LDate)-MONTH(EDate)

Now these are two fairly long and complicated formulas and you really don’t need to understand what’s going on.

Advertisement

Note the you should edit the round down formula in the actual cell itself because for some odd reason the entire formula does not show up in the formula bar. In order to see the formula in the cell itself, click on the Formulas tab and then click Show Formulas.

So what’s the final result of the two formulas on our current example? Let’s see below:

Round up gives me 27 months and round down gives me 26 months, which is accurate, depending on how you want to look at it. Lastly, you can also use the DATEDIF function, but it only calculates full months, so in our case the answer it returns is 26.

=DATEDIF(A2, A3, "M")

## Years Between Two Dates

As with months, years can also be calculated depending on whether you want to count 1 year as a full 365 days or if a change in the year counts. So let’s take our example where I have used two different formulas for calculating the number of years:One formula uses DATEDIF and the other uses the YEAR function. Since the difference in the number of days is only 802, DATEDIF shows 2 years whereas the YEAR function shows 3 years.

Again, this is a matter of preference and depends on what exactly you are trying to calculate. It’s a good idea to know both methods so that you can attack different problems with different formulas.

As long as you are careful with which formulas you use, it’s fairly easy to calculate exactly what you are looking for.

Advertisement

Author: Aseem Kishore

.

Was my post useful? Support me to keep creating useful content

**Disclaimer** If this post is your copyrighted property, please message this user or email us your request at team@pejoweb.com with a link to this post

15 likes

Advertisement

Advertisement