We can use Excel to clean text fields, extract specific information from text fields, or join text fields together.

Let’s have a look at the example below where have some text fields extracted from a database (columns A to E) and we would like to do some manipulations over them in the green columns F to J.

*You can download the sample workbook from here.*

In the first column, we have the State-Zip codes. We know that the state is the first 2 letters from the left, and the Zip code is the 5 numbers from the right. Let’s separate those to have the state in column F and the Zip code in column G.

To do this, we use the functions LEFT and RIGHT.

In cell F2, we type =LEFT and open a bracket. Then we will find 2 arguments. The first one is the text, which in this case is the State-Zip cell, and then the number of characters, which is 2 since we need only the first 2 characters. We then drag the formula along the column.

To do this, we use the functions LEFT and RIGHT.

In cell F2, we type =LEFT and open a bracket. Then we will find 2 arguments. The first one is the text, which in this case is the State-Zip cell, and then the number of characters, which is 2 since we need only the first 2 characters. We then drag the formula along the column.

For the Zip code, we go to cell G2, and type =RIGHT then open a bracket, and again the same 2 arguments are the text and number of characters. In this case the number of characters will be 5 since we need the 5 characters from the right. We then drag the formula along.

Next, we see that in columns B and C we have first names and last names respectively. Now we need to join these 2 names together to form the Full Name in column H. There are 2 ways to do this.

The first one is using the CONCATENATE function. We go to cell H2, type CONCATENATE, open a bracket, and type as many texts as you need to join, separated by a comma.

The first one is using the CONCATENATE function. We go to cell H2, type CONCATENATE, open a bracket, and type as many texts as you need to join, separated by a comma.

When we concatenate cells B2 and C2, we find that the result in H2 actually joins the 2 names but without any spaces in between. We can include the space as an argument in the concatenate function by typing space between speech marks (i.e. “ “). The final formula and result will look like this:

The second way to join text strings is using the Ampersand sign "&" (which you can type using Shift + 7 on your keyboard).

To do this, we don’t have to use any functions. We just type the = sign, choose the text and then join it using the & sign with another text and so on. The formula will look like this:

To do this, we don’t have to use any functions. We just type the = sign, choose the text and then join it using the & sign with another text and so on. The formula will look like this:

Note that we joined the space “ “ with a & sign as well.

Now let’s extract the product model from the product number in column D. We know that the model is the 2 letters in the middle of the product number (i.e. in 475AR9096, the model is AR).

To do this, we use the MID function. We go to column I, type MID and open a bracket. We see that the MID function has 3 arguments:

The final output will look like this:

Now let’s extract the product model from the product number in column D. We know that the model is the 2 letters in the middle of the product number (i.e. in 475AR9096, the model is AR).

To do this, we use the MID function. We go to column I, type MID and open a bracket. We see that the MID function has 3 arguments:

- The first one is the
**text**: this is the text string which is the product number. - The second argument is the
**start_num**: this is the starting point of the text we need to extract. We start from the left side, and count the number of characters until we find the text to be extracted. In our example, we counted 3 numbers and then the model is the 4th character from the left, so we type 4. - The third argument is the
**num_chars**: this is the number of characters that we need to extract. So after I counted 4 characters from the left in the previous argument, how many characters to do we need to extract? In this case the Model is only 2 characters, so we just type 2.

The final output will look like this:

Finally, we would like to clean the Web Site column because it includes a lot of spaces either before or after the text strings (it’s obvious in some fields, but not very obvious in other fields where the space comes at the end of the text. You can examine this further in the worksheet yourself).

To clean this, we use the TRIM function which basically removes any additional spaces before or after any text. To use it, we just type TRIM and choose the text we need to clean. It’s very straight forward.

To clean this, we use the TRIM function which basically removes any additional spaces before or after any text. To use it, we just type TRIM and choose the text we need to clean. It’s very straight forward.

As a bonus step, we can precede the result with a “www.” and finish it with a “.com” for a better display of the website using CONCATENATE function or the & sign.

Now we have seen how can you use Excel to extract, join, separate or clean text strings. Now go ahead and try it on your own data. Feel free to post your questions in the comments field below.

Happy Excelling!

Happy Excelling!

Let’s start with IFERROR. IFERROR is actually an extension to the IF function. It tells Excel what to do with other formulas when it can’t find the answer or when it returns an error.

Looking at the same example we have been using in the VLOOKUP and IF functions tutorials, we would like to see how to handle a VLOOKUP function when a city is not found (i.e. check the VLOOKUP example to understand the context).

*YOU CAN DOWNLOAD THE EXAMPLE WORKSHEET FROM HERE*

In this case we will use IFERROR with VLOOKUP to give a custom message when Excel can’t find what it’s looking for. We see below that Oxford can’t be found in the lookup table. So instead of Excel returning an error #N/A, we would like it to return “Not Found”.

In this case we will use IFERROR with VLOOKUP to give a custom message when Excel can’t find what it’s looking for. We see below that Oxford can’t be found in the lookup table. So instead of Excel returning an error #N/A, we would like it to return “Not Found”.

To do this, we go to the first formula in the formula bar, and just before the VLOOKUP function just type IFERROR and open a bracket.

The first argument of the IFERROR is the value. This is the value that we want Excel to return. In this case it’s the country from the lookup table so that's why we kept the VLOOKUP function untouched.

The second argument is the value_if_error. This is what we want Excel to return when there is an error (i.e. when the city we are looking for is not found). In this case we would like to return “Not Found”, so we type Not Found between speech marks “” (since it's text), close the bracket, hit Enter, and then drag the formula.

We will see that Oxford now shows Not Found instead of showing an error.

The second argument is the value_if_error. This is what we want Excel to return when there is an error (i.e. when the city we are looking for is not found). In this case we would like to return “Not Found”, so we type Not Found between speech marks “” (since it's text), close the bracket, hit Enter, and then drag the formula.

We will see that Oxford now shows Not Found instead of showing an error.

Now, what if I have more than one lookup table, and I wanted Excel to look up another table when the value I’m looking for is not found in the first table.

Let’s make another table with only the city Oxford in it, and we will use this as our second lookup table (it's a relatively small table that we make for the sake of the example).

Let’s make another table with only the city Oxford in it, and we will use this as our second lookup table (it's a relatively small table that we make for the sake of the example).

Now to make this work, we go to our first IFERROR formula, and instead of typing “Not Found”, we will type another VLOOKUP function to lookup the other table with Oxford in it.

By doing this, I’m asking Excel to lookup Oxford in the first table (this is the first VLOOKUP), and if it’s not found (i.e. it returned an error), look it up in the second table. And as shown below, it works perfectly as desired.

By doing this, I’m asking Excel to lookup Oxford in the first table (this is the first VLOOKUP), and if it’s not found (i.e. it returned an error), look it up in the second table. And as shown below, it works perfectly as desired.

Now to make it a bit harder, let’s consider another scenario where we have another city that is not included in both lookup tables (note the city Chester below).

So now we would like Excel to return a custom message instead of the error #N/A.

This is where we use what's called "nested formulas". Nested formulas are basically a formula inside a formula. Meaning the we will use an IFERROR inside an IFERROR. I know this might sound confusing, but it’s actually not. Just follow along.

The logic that we want Excel to follow is the following:

So let’s see how the above logic can be applied into our formula. Our initial formula satisfied only 2 conditions from the above logic (conditions 1 and 2):

This is where we use what's called "nested formulas". Nested formulas are basically a formula inside a formula. Meaning the we will use an IFERROR inside an IFERROR. I know this might sound confusing, but it’s actually not. Just follow along.

The logic that we want Excel to follow is the following:

- Return the country by looking up the city in the first table
- If it’s not found (i.e. returned an error), lookup the city in the second table
- If it’s not found again, return the message “Not Found”

So let’s see how the above logic can be applied into our formula. Our initial formula satisfied only 2 conditions from the above logic (conditions 1 and 2):

Now to update this formula to satisfy the 3 parts of our logic, we will need to include another IFERROR function before the second VLOOKUP. So the final formula will look like this:

Once we apply it, it will work exactly as intended:

So this is how you use IFERROR to clean up your data when there are errors in your formulas.

Now let’s see how ISERROR works in dealing with errors in Excel.

What ISERROR does is that it returns a True or False of whether or not there is an error.

So what we will do is that we will add a new column called “In Table?” and check if whether or not the cities are found in the lookup table.

So we go to the formula bar and type = ISERROR and then our VLOOKUP formula.

Note that there is only 1 argument in the ISERROR function and that’s because it returns either True or False.

Now let’s see how ISERROR works in dealing with errors in Excel.

What ISERROR does is that it returns a True or False of whether or not there is an error.

So what we will do is that we will add a new column called “In Table?” and check if whether or not the cities are found in the lookup table.

So we go to the formula bar and type = ISERROR and then our VLOOKUP formula.

Note that there is only 1 argument in the ISERROR function and that’s because it returns either True or False.

So the formula returned FALSE for all the cities except for Oxford and Chester since they are not found in the lookup table and their VLOOKUPs returned an error (thus, it's TRUE, it has an error).

Now let’s clean this a little bit further. Let’s wrap an IF function around this formula to return “Found” if the city was found in the lookup table, and “Not Found” if it wasn’t there.

So the formula should look like this:

Now let’s clean this a little bit further. Let’s wrap an IF function around this formula to return “Found” if the city was found in the lookup table, and “Not Found” if it wasn’t there.

So the formula should look like this:

What happened here is that Excel did the VLOOKUP and checked, was the result an error? If it was an error, then “Not Found” is returned. Otherwise, “Found” is returned.

So this is another typical example of nested formulas. We used IF, ISERROR and VLOOKUP functions all in one formula. We could have done each separately in separate columns and separate formulas, but with this nested formula capability, we were able to save time and space by compiling all of them together in just one formula. It also makes your worksheet much tidier.

Now go ahead and try these handy functions with your data. Feel free to post your questions in the comments section below.

Happy Excelling!

So this is another typical example of nested formulas. We used IF, ISERROR and VLOOKUP functions all in one formula. We could have done each separately in separate columns and separate formulas, but with this nested formula capability, we were able to save time and space by compiling all of them together in just one formula. It also makes your worksheet much tidier.

Now go ahead and try these handy functions with your data. Feel free to post your questions in the comments section below.

Happy Excelling!

Let’s jump directly to our example.

We have this table that we used in previous examples. It contains the city, the population and the country. We would like to run an IF formula in column D, to see if whether or not the country in column C is Scotland or not. If it’s Scotland, the formula should return Yes, if it’s not Scotland the formula should return No (you can download the example file from here).

We have this table that we used in previous examples. It contains the city, the population and the country. We would like to run an IF formula in column D, to see if whether or not the country in column C is Scotland or not. If it’s Scotland, the formula should return Yes, if it’s not Scotland the formula should return No (you can download the example file from here).

So we go to the formula bar, type = then if then open a bracket.

We have 3 arguments in the IF function:

1- First argument: Logical test

This is the logic, condition or criteria that we want to test. In our example, we want to test if the country in column C is Scotland. The formula will be:

1- First argument: Logical test

This is the logic, condition or criteria that we want to test. In our example, we want to test if the country in column C is Scotland. The formula will be:

And note that Scotland is between speech marks “” because it’s text.

2- Second argument: Value if True

This is what I would like to return if the test is true. So if the country is Scotland, I want the formula to return the word “Yes”. So I simply type “Yes”, again between speech marks.

2- Second argument: Value if True

This is what I would like to return if the test is true. So if the country is Scotland, I want the formula to return the word “Yes”. So I simply type “Yes”, again between speech marks.

3- Third argument: Value if False

This is what I would like to return if the test is false. So if the country is not Scotland, I want the formula to return the word “No”. So again I simply type “No”.

Now the formula is ready and I can drag it across the rows.

This is what I would like to return if the test is false. So if the country is not Scotland, I want the formula to return the word “No”. So again I simply type “No”.

Now the formula is ready and I can drag it across the rows.

Now let’s try another example with numbers. We would like to run a test to see if the population per city is greater than a specific number, say 500,000.

In a new column (Column E), we will be putting our criteria which is >500K.

So if this criteria is true, we would like to return the population of the city, if it’s false, we’d return the text “Under 500K”.

So the formula will look like this:

In a new column (Column E), we will be putting our criteria which is >500K.

So if this criteria is true, we would like to return the population of the city, if it’s false, we’d return the text “Under 500K”.

So the formula will look like this:

Note that in the first argument (the logical test) and in the second argument (value if true) we didn’t put the numbers between speech marks “” because numbers are recognized by Excel directly and don’t need speech marks. Only text is being put between speech marks and that’s what we have done in the last argument (value if false).

Now when we drag the formula across the rows, we can easily identify which cities have a population over 500K and which don’t.

Now when we drag the formula across the rows, we can easily identify which cities have a population over 500K and which don’t.

IF function are one of the most commonly used functions in Excel, and they are widely used for validations. Try practicing it with your own data, and feel free to post your questions here in the comments if you have any.

Happy Excelling!

Happy Excelling!

What VLOOKUP allows you to do is that if you've got 2 tables and you got 1 common field in these 2 tables, you can pull data from one table into the other table. Meaning that you can look up this common field from table 1, find it in table 2 and return any other field from table 2.

Let’s say for example we have these 2 tables below (you can download the example file from here). One showing the city and the population of each city, and the other table is showing the city and its relative country. So the common field here is the city. Although they may not be listed in the same order, but that’s fine. We need to make sure there is a common field between them. So what we can do is look up each city from table 1 in table 2, and return the country field to table 1. You may think of VLOOKUP as your "find and return" soldier.

The V here stands for Vertical, because we are looking up values in a vertical table. It’s twin is the HLOOKUP in which you use when looking up in a horizontal table.

Now this is how VLOOKUP works. Go to the formula bar, type VLOOKUP and open bracket.

The first argument here is the**lookup value**: This is the common field (in Table 1) that you are going to look up in the other table (Table 2). In this case it’s going to be the city London.

The second argument is going to be the**table array:** Where are you going to lookup the work London? So I choose the whole Table 2 in columns I and J.

The third argument is the**column index number:** This is how many columns across do you want to return data from; including the first column. So in Table 2, country is in the second column, so I just type 2.

The final argument is where you choose either**TRUE** or **FALSE:** This tells Excel what you want it to do if it didn’t find the value you are looking for. Do you want it to return and error (FALSE) or do you want it to return the closest match (TRUE).

When you select TRUE, if Excel didn’t find London in the lookup table, it will try to find the closest alphabetical match, which is probably Liverpool. But we don’t want that because it will be misleading and messing up the data for us. So we will choose FALSE. Actually, 99% of the time, I’ve used FALSE and I can barely remember when was the last time I chose TRUE.

Note that Excel recognizes TRUE and FALSE as 1 and 0 respectively. So instead of typing FALSE, we can just type 0 and it works the same way.

Now this is how VLOOKUP works. Go to the formula bar, type VLOOKUP and open bracket.

The first argument here is the

The second argument is going to be the

The third argument is the

The final argument is where you choose either

When you select TRUE, if Excel didn’t find London in the lookup table, it will try to find the closest alphabetical match, which is probably Liverpool. But we don’t want that because it will be misleading and messing up the data for us. So we will choose FALSE. Actually, 99% of the time, I’ve used FALSE and I can barely remember when was the last time I chose TRUE.

Note that Excel recognizes TRUE and FALSE as 1 and 0 respectively. So instead of typing FALSE, we can just type 0 and it works the same way.

Now we drag this formula to the rest of the cells in the table. But something goes wrong. We see a lot of errors, which means the city was not found in the lookup table, or this is caused by something else.

Let’s investigate through the first probability. It seems that all the cities in Table 1 exists in Table 2.

So let’s go check the formula in one of the cells that is giving me an error. If we double click on one of them, we will see that the lookup range has been dragged with me, thus missing some of the cities.

So let’s go check the formula in one of the cells that is giving me an error. If we double click on one of them, we will see that the lookup range has been dragged with me, thus missing some of the cities.

To fix this, we need to always make sure the lookup range is absolute (by choosing the range in the formula bar and hitting the F4 key) before dragging it.

Making the range absolute will show as a $ sign before the row and the column references.

Making the range absolute will show as a $ sign before the row and the column references.

Now when we drag again from the first cell in the column (cell C2), the results will be displayed correctly.

Another way instead of making the range absolute is that we can choose the whole range of I and J columns instead of choosing exactly cell I1 to J21.

This is helpful in many ways:

Now let’s try to delete London from the lookup table and see what happens.

- You don’t have to worry about forgetting to make the lookup range absolute.
- If you added more cities and countries in Table 2, you don’t have to go and update the range of the VLOOKUP formula. The new ranges will be included automatically.

Now let’s try to delete London from the lookup table and see what happens.

I got an error instantly in Table 1 in the country field.

Now let’s try to update the formula VLOOKUP formula to have the last argument as TRUE instead of FALSE (I’ll just type in 1).

Now let’s try to update the formula VLOOKUP formula to have the last argument as TRUE instead of FALSE (I’ll just type in 1).

So Excel have looked for a similar city to London in terms of the letters in the word London.

To know which city, let’s change the 3rd argument (column index number) in the VLOOKUP formula to 1, so that it returns the city instead of the country. So it returned Liverpool, which is the closest alphabetical match to London in the lookup table.

To know which city, let’s change the 3rd argument (column index number) in the VLOOKUP formula to 1, so that it returns the city instead of the country. So it returned Liverpool, which is the closest alphabetical match to London in the lookup table.

But remember, we don’t want that. And I strongly advice to be very careful when choosing the approximate match because otherwise you can have flawed data and it will be hard to investigate the root cause.

A couple of important things to note about VLOOKUP:

Now go ahead and practice some VLOOKUPs. If you get stuck, feel free to post any questions here in the comments section.

Happy Excelling!

A couple of important things to note about VLOOKUP:

- The lookup range doesn’t have to be in the same worksheet you are displaying the results in. It could be in a different worksheet, or an entirely different workbook.
- The common field which is the city MUST be to the left of the field you want to return. It doesn’t have to be the first field, but it has to be on left of any fields you are returning.

Now go ahead and practice some VLOOKUPs. If you get stuck, feel free to post any questions here in the comments section.

Happy Excelling!

There are a lot of Date functions in Excel, but I will go through the most useful ones.

The first one is TODAY. If we type =today() in the formula bar we will get today’s date.

Now if you close this file now, and reopen it tomorrow, you will get tomorrow’s date.

Just note that my computer settings are set so that days display as MM/DD/YYYY. To change how your computer displays date, you can go to the control panel, Region & Language, and set how you want to display the dates

Just note that my computer settings are set so that days display as MM/DD/YYYY. To change how your computer displays date, you can go to the control panel, Region & Language, and set how you want to display the dates

From this date cell, I can get the day of a specific date. I type =day and then reference the date that I want to get it’s day for.

If I want to get the month, what do I type? Exactly, I type =month and reference the date.

Year works the same way.

Now what if I want to get the name of the day (i.e. Sunday, Monday, etc…). Now a name is a text string, so the formula to convert the day to text is simply =text( then I reference the date (which is called value in the argument), and then put the format.

So days in Excel are formatted in dddd and each “d” represents a format type. If it’s 1 or 2 d’s, then it will show the day number formatted as text.

So days in Excel are formatted in dddd and each “d” represents a format type. If it’s 1 or 2 d’s, then it will show the day number formatted as text.

If it’s 3 d’s it will show the first 3 letters of the day (Sunday will be shown as Sun).

If it’s 4 d’s it will show the whole day name.

For the month, it’s the same. But instead of putting d’s, we put m’s (m for Month).

This is not going to work for the year since years has no names.

Now imagine that you received a data set that has the days, months and years separated and you would like to get them together into a date.

In this case, we use the DATE function, where you type in Date(then you reference the year first, then month, then day.

In this case, we use the DATE function, where you type in Date(then you reference the year first, then month, then day.

This way you will be having a proper DATE to work with.

Now let me remind you of one thing. Excel only understand numbers and text strings. And it can do calculations over numbers.

For Excel, a date is a serial number.

To demonstrate this, let’s change the format of the date that we have to a number.

Now let me remind you of one thing. Excel only understand numbers and text strings. And it can do calculations over numbers.

For Excel, a date is a serial number.

To demonstrate this, let’s change the format of the date that we have to a number.

You will see that it turn to 42989.

Now what is this number?

Ok before I tell you, let’s try something. Let’s type 1, and then format it to short date.

Ok before I tell you, let’s try something. Let’s type 1, and then format it to short date.

So it shows 1st of Jan 1900. So this is the first date that Excel recognizes.

And the 42989 means that 9/11/2017 is 42988 days after the first date in Excel which is 1/1/1900

And since dates are just numbers in Excel, this means we can do a lot of calculations over it.

Now let’s put another date, say 31st Dec 2017. And let’s see how many days are between this date and our date.

We just do a simple subtraction. If we subtract 9/11/2017 from 12/31/2017, we will get how many days are between the 2 numbers (or 2 dates).

And since dates are just numbers in Excel, this means we can do a lot of calculations over it.

Now let’s put another date, say 31st Dec 2017. And let’s see how many days are between this date and our date.

We just do a simple subtraction. If we subtract 9/11/2017 from 12/31/2017, we will get how many days are between the 2 numbers (or 2 dates).

Now let’s assume we want to know how many days are between the 2 dates excluding the weekends (because 111 typically includes the weekends).

There is an amazing function called NETWORKDAYS

So we type NETWORKDAYS, then we choose the second one which is the international one and I will tell you why in a second.

There is an amazing function called NETWORKDAYS

So we type NETWORKDAYS, then we choose the second one which is the international one and I will tell you why in a second.

So we start by entering the start date, the end date, choose the weekend. You’ll see that we have a wide range of weekends, and you can choose the one relevant to your country.

I will choose 7, which represents Fridays and Saturday. Then the last argument here is the holiday, but let’s ignore for now and come back to it later.

So now you see we have 80 days, which are the working days between 09/11/17 and 12/31/17.

So now you see we have 80 days, which are the working days between 09/11/17 and 12/31/17.

Now the reason I chose the NETWORKDAYS.INTL is that the normal NETWORKDAYS function doesn’t have a weekend argument, and it just considers the standard weekend in the US which is Saturday and Sunday.

Now what if I want to see the number of days between 2 dates excluding weekends and public holidays?

This is where the last argument in the function comes into play.

So let’s input any set of dates and consider these dates as public holidays.

This is where the last argument in the function comes into play.

So let’s input any set of dates and consider these dates as public holidays.

Then we choose this range in our formula and we get the number of days excluding holidays and weekends.

But wait a second, I should get 76 days since I have 4 days as public holiday (it’s 80 – 4 right?). Then how come?

Well, that’s right, but let’s see why this happened. Let’s use the TEXT function to convert those holidays into day names and see if any of them comes on a weekend.

Well, that’s right, but let’s see why this happened. Let’s use the TEXT function to convert those holidays into day names and see if any of them comes on a weekend.

Aha. There is a date that comes on a Friday, and it’s a weekend in my NETWORKDAYS.INTL function, so the function was smart enough to not double count it as a holiday and as a weekend.

The last thing I would like to show you is adding to dates. Let’s imagine a scenario where you would like to add days to a specific date.

So we add 30 days to our date and we get a date that is exactly one month after our date.

The last thing I would like to show you is adding to dates. Let’s imagine a scenario where you would like to add days to a specific date.

So we add 30 days to our date and we get a date that is exactly one month after our date.

But this date is exactly 30 days after our date, which means it includes the weekends.

Now what if we want to see a date that is 30 days after a specific date EXCLUDING weekends?

There is a formula for that, and it’s WORKDAY

So we type WORKDAY.INTL (again to have the option to choose between different weekends), type our start date, the number of days, weekend (this time we choose Friday only), and the range of holidays.

Now what if we want to see a date that is 30 days after a specific date EXCLUDING weekends?

There is a formula for that, and it’s WORKDAY

So we type WORKDAY.INTL (again to have the option to choose between different weekends), type our start date, the number of days, weekend (this time we choose Friday only), and the range of holidays.

So 30 “working days” after Sep 11th will be Oct 17th.

Now go ahead and try out these functions and formulas. If you have any questions, feel free to post them here in the comments.

Now go ahead and try out these functions and formulas. If you have any questions, feel free to post them here in the comments.