Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?
In an ideal world, you wouldn't need to read this tutorial about some of the most important text formulas in Excel.

Unfortunately, we are not in ideal world…

If you work with Excel, you will need to know or learn how to use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions.

So… fortunately, you have found this tutorial which focuses on some of the most important text functions in Excel.

In this particular Excel tutorial, I explain step-by-step how you can use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions in Excel.

The following table of contents illustrates, more precisely, the topics we cover in this blog post. You can also use it to skip to the section that interests you the most.

This is a massive amount of content, so let's begin by understanding…

Why You Should Learn How To Use The LEFT, RIGHT, MID, LEN, FIND And SEARCH Functions In Excel

You may rightly wonder why should you study this comprehensive 11,000+ word tutorial on Excel text formulas to learn how to use some of the most common Excel text functions.

There are several reasons why knowing how to use functions such as LEFT, RIGHT, MID, LEN, FIND and SEARCH is important. But instead of simply listing a bunch of reasons, allow me to ask you a question:

When working with Excel, there are times where you have to use data prepared by other people or companies. Based on your experience, how does this data look like? If you have never worked with data sets prepared by somebody else, please make a guess.

  • Is it the data set clean, organized, and properly and consistently formatted?
  • Or is it messy, disorganized, full of clutter and inconsistently formatted?

Let's face it…

When you receive data prepared by other people or companies, you will need to clean up the data before you can proceed to work with it. In some cases, the data sets will be a complete mess.

And let's not even talk about the situations where you have to work with several data sets, all prepared by different people who have completely different ideas about how the data should be organized (or disorganized).

When you use data from other sources, it's usually not ready for analysis. Data scientists spend approximately 80% of their time in the process of gathering and cleaning up data before they can actually begin to analyze it.

The problem of messy data, however, is not exclusive to data analysts. There are many (other) examples. The main point to remember is that data quality is important. Therefore, knowing how to clean up data is essential.

What is the main take-away from the above?

You will need to clean up data. There is no question about it.

Sometimes you may also feel like this:

In order to avoid this type of situation, let's ask a more relevant question: how will you clean up the data?

Will you do it manually? With the risks of missing errors or introducing new errors? Not to mention the amount of time cleaning up a large data set manually would take or how tedious the work would be…

Or will you automate the data clean-up process as much as possible to make it more streamlined and reliable?

If you are interested in learning how you can start automating the data clean-up process in Excel, keep reading. This Excel tutorial will make you significantly more efficient and productive, and reduce the risk of office violence.

I show you, step-by-step and using a very detailed example, how you can start using the LEFT, RIGHT, MID, LEN, FIND and SEARCH Excel functions now to improve your efficiency and productivity in Excel now.

You may be surprised by what you can do with Excel's text functions. As explained by John Walkenbach in the Excel 2013 Bible:

(…) some of these formulas perform feats that you may not have thought possible.

Just as an example, quoting Excel Formulas and Functions for Dummies, mastering functions such as LEFT, RIGHT and MID “gives you the power to literally break text apart.”

Does this sound useful?

Then let's start by understanding…

What Are Excel Text Functions

When you think about Excel, working with text is probably not the first thing that comes to your mind…

That is completely natural. After all, Excel is not a word processor… If you need a word processor, you can use Microsoft Word.

However, you may be surprised by Excel's capabilities to handle and work with text. This is where Excel text functions come in…

Excel text functions are, as implied by their name, functions you can use to work with text or strings. For these purposes, as explained by John Walkenbach (one of the foremost authorities on Microsoft Excel) in the Excel 2013 Bible, text and string (and sometimes text string) are used interchangeably.

Despite the above, Walkenbach also explains how “many text functions are not limited to text” and, therefore, you can also use some of Excel's text functions in cells that have numbers.

Excel has several text functions, which you can find by going to the Formulas tab of the Ribbon and clicking on “Text” or using the keyboard shortcut “Alt + M + T”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

What Is “Text”

I'll ask you a question that may sound a little bit basic but, do you know what is text?

And I don't mean regular text. I assume that, if you are reading this Excel tutorial, you know what is the usual definition of the word “text”.

The question is actually tricky because, in Excel, some things are slightly different from what you'd usually expect…

In Excel 2013 Formulas, John Walkenbach explains that whenever you type data, “Excel immediately goes to work and determines whether you are entering” one of the following:

  • A formula.
  • A number, which includes regular numbers, dates and times.
  • Text, which is anything other than a formula or a number.

Believe it or not, it's actually possible for Excel to treat a number as text. This is not that uncommon and, in some cases, can be quite annoying, such as when you are importing data into Excel.

It can also be quite dangerous as Excel does not always treat numbers that are formatted as text in the same way.

Let's take a very simple example. The following Excel worksheet has two numbers in cells B1 and B2 (both numbers are 1). Cells B3 and B4 are reserved for the sum of these two numbers which you would expect to be 2 (as 1+1=2, right?).

Notice, however, that the numbers in cells B1 and B2 do not have the same alignment. The “1” in cell B1 is aligned to the left whereas the “1” in cell B2 is aligned to the right. This is because I have formatted cell B1 as text, something I may explain in future tutorials, and have not modified the alignment.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Now… let's do some magic and see how, sometimes, 1 plus 1 doesn't equal 2…

The screenshot below shows the result of calculating the sum of cells B1 and B2 using two different methods:

  • In cell B3, the sum has been carried out by using the formula =B1+B2, as it appears in the parenthesis within cell A3.
  • In cell B4, the sum has been calculated with the formula =SUM(B1:B2), as it appears inside the parenthesis in cell A4.

    You can actually check out the formula bar to confirm that this is indeed the formula in the cell.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Don't worry, you don't have to go back to math lessons to review sums. Excel is indeed giving different treatments to cell B1 depending on which formula is used. In these cases, the SUM function treats cell B1 as a 0 and results in the sum of 1+1 not being equal to 2.

In this particular case, Excel indicates that there is a possible error (see the warning in the screenshot above) and the number in cell B1 is stored as text. According to John Walkenbach in Excel 2013 Formulas, this is usually the case (that Excel identifies the cell) if you have background error checking enabled.

However, as Walkenbach himself explains:

(…) be aware of Excel's inconsistency in how it treats a number formatted as text.

Perhaps even better, be careful in general when using the text format and, when in doubt, use the general format.

Now that you know what exactly is “text” within Excel, allow me to introduce the example that I use in this tutorial on Excel text formulas:

Example Of How To Use The LEFT, RIGHT, MID, LEN, FIND And SEARCH Functions In Excel

My main business (as of the time of writing of this blog post) is real estate.

As you can imagine, our real estate company has to work a lot with addresses. Addresses for plots of land, buildings, houses and so on. You get the idea…

Sometimes we receive these addresses in big data sets prepared by somebody else and, as you may expect, their idea about how a database should be organized is different from mine.

Therefore, we constantly have to go through the process of cleaning up and fixing address data.

Address data is not only relevant for the real estate and construction industry. Databases where addresses can appear include, for example, the following:

  • If you focus on sales, you may work constantly with lists of customers and may have to keep an organized list with their contact details.
  • If you work at a company that operates several shops or branches, you may need to keep track of their individual addresses.

Therefore, the example I use to explain you how to use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions in Excel focuses on address data. More precisely, I take an address that I receive in a particular format and split the address into its different parts using Excel.

For these purposes, I have created 1,000 random addresses using a random address generator. They have all been pasted into a single column of an Excel worksheet.

This Excel Text Functions Tutorial is accompanied by Excel workbooks containing the data and formulas I use. You can get immediate free access to these example workbooks by subscribing to the Power Spreadsheets Newsletter.

The column with the full addresses in the initial Excel worksheet looks as follows:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Do you see any problems with the way this address list is organized?

Granted… it's possible to get messier data. In this case all the addresses follow the same format, names are properly capitalized and, generally, the data looks relatively clean.

However, the data is organized in a way that may make it difficult to analyze using more advanced tools such as filters or PivotTables (topics I may explain in future tutorials). For example:

  • Every single address is divided in two rows. The top row shows the street and number while the second row includes the city, state and zip code.

    Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

    This is not very convenient if, for example, you want to have all the data of each customer in a single row.
  • Within a row, there are several details. As mentioned above, the first row includes both the street and number, and the second row lists the city, state and zip code.

    Depending on the type of analysis you want to carry out with the data, it may be more useful if you are able to split these elements and show each item in a separate cell.

As a consequence of the above, I show you how to:

  • Convert all addresses into a single row.
  • Separate the elements of each address so that each item has its own individual cell.

More precisely, I show you step-by-step how to fill out the following table using Excel text formulas:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The steps in this example are chosen and structured considering that the main purpose is to show you, going slowly and step-by-step, how to use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions in Excel so you can apply and adapt these formulas by yourself later in different situations. There are other ways to achieve the same or similar results by using methods such as nesting functions within other functions, the text to columns command or, in some cases, slightly simpler formulas or tools that do not involve the LEFT, RIGHT, MID, LEN, FIND or SEARCH functions.

In certain cases, those other methods may be more appropriate and efficient to achieve your particular objectives. For example, instead of creating several columns (as I do in the process below), you can create a few nested functions that carry out all the required processes in less cells or use the text to columns command to parse the data.

However, nested functions, text to columns and similar tools deviate from the main purpose of this Excel tutorial: showing you how to use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions.

I agree, however, that there are different ways to perform the actions described in this Excel tutorial and I'm very interested in hear which other methods you would use to organize the addresses above. Please share your ideas and comments about how you would improve the process in the comments at the end of this guide.

I also mention and use some functions than are not explained in depth in this Excel tutorial, such as VALUE, ISNUMBER, IF and CONCATENATE. I may cover them in detail in future tutorials.

Are you ready?

Then let's go on to the step-by-step explanation of how to use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions in Excel to fix these addresses.

Step #1: How To Use The LEFT Function In Excel To Determine Whether The First Character In A Cell Is A Number

One of the main problems with the original address list is that each address is spread over two rows of data.

Therefore, in the first few steps of this example, I show you how to solve this problem and get each address into a single row.

If you take a close look at the addresses, you'll notice that the first row (where the street and number are) always begins with a numeric character while the second row (where the city, state and zip code appear) begins with an alphabetic character.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can use this fact to distinguish between the rows of a single address. More precisely, you know that:

  • If the first character in a cell is a number, this is the first row of the address.
  • If the first character in a cell is not a number, this is the second row of the address.

So, the first thing you want Excel to do is determine whether the first character in a cell is a number or not.

I explain below, step-by-step, how you can do this:

1. Step #1: Use The LEFT Function To Grab The First Character Of The String.

The LEFT function allows you to find what the first characters in a text string are. You get to choose the number of characters that the LEFT function returns.

What is the syntax of the LEFT function?

The syntax of the LEFT function is “LEFT(text,num_chars)”, where:

  • “text” is the text from which you want to extract the characters.Here is where you tell Excel the location of the string from which you want to grab the characters or type the text within quotes “” (for example “This is the best Excel tutorial”).
  • “num_chars” is the number of characters you want to extract.The main requirement that num_chars must meet is that it can't be a negative number. You can, however, specify a number of characters that is larger than those contained in the original string. In this case, the LEFT function simply returns the whole text.

    You can also leave num_chars blank (omit it), in which case the LEFT function assumes it is 1 and return the first character of the text string.

So, how do you use the LEFT function to grab the first character of the addresses that are being cleaned up in the example?

For illustration purposes, I first create an additional column in the Excel worksheet that contains the addresses. This is column C and is titled “First Character”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Now, let's take a look at the syntax of the LEFT function, “LEFT(text,num_chars)”. In this case:

  • “text” is the text located in column B.
  • “num_chars” is 1.

    It's also possible to leave num_chars blank so that Excel assumes it is 1.

So the LEFT function is “LEFT(B#,1)”, where # is the number of the relevant row. For example, the formula for cell C3 is “=LEFT(B3,1)”:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And, in this case, the LEFT function returns 8, which is the first character of the address 857 King Street.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Now, you can copy and paste this formula across the 2,000 rows of data to get the LEFT function to return the main character of every single cell in the address list.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

2. Step #2: Convert The Character You Have Extracted From The Text String Into A Number.

You are already aware of how, sometimes, Excel does not treat numbers as numbers. Remember how, above, I showed you that sometimes 1+1 is not equal to 2.

A similar thing may happen to the cells where the output of the LEFT function are.

For example, if you were to use the ISNUMBER function, which allows you to check if a value is a number and returns TRUE (if it is a number) or FALSE (otherwise) on cell C3 (which displays the number 8), the results are as follows:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Meaning that, according to Excel, the value in cell C3 is not a number.

To ensure that this does not cause any problems down the road, I convert the character that has been extracted from the text string to a number using the VALUE function. The VALUE function converts any text string that represents a number to an actual number for Excel purposes.

I may cover the VALUE function in detail in future Excel tutorials.

For the moment, is enough to know that the VALUE function has a single parameter which is the text that is converted to a number. In the example used in this Excel tutorial, this is the text located in column C.

Before applying the VALUE formula I add a new column to the Excel worksheet. This is column D titled “First Character Value”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

In this case, the formula for cell D3 is “=VALUE(C3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And the result is the number 8:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can copy and paste the formula in all the cells of column D to convert all of the text values that represent numbers in column C to actual numbers. Note that, in the cases where column C does not contain a number, but has a letter, the VALUE function returns “#VALUE”.

I fix this below.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

3. Step #3: Check Whether The Character You Have Extracted Is A Number Or Not.

The ISNUMBER function allows you to check if a value is a number. If the value is indeed a number, ISNUMBER returns TRUE. If the value is not a number, ISNUMBER returns FALSE.

You can use the ISNUMBER function to check whether the first character you have extracted from the column of addresses is a number or not.

I may explain more about the ISNUMBER function in future Excel tutorials but, for the moment, is enough to know that ISNUMBER has a single parameter. This parameter is the particular value that you want Excel to test.

As usual, let's add a new column to the Excel worksheet. This is column E and its title is “Is First Character a No.?”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The formula for cell E3 is “=ISNUMBER(D3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And the function returns TRUE, indicating that the value in cell D3 (and therefore the first character in the address) is a number.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can copy and paste the formula in all the cells of column E to have Excel evaluate the values of the first character of the original text string. Notice how Excel, correctly, returns TRUE in the cases where the first character of the address cell is a number and FALSE when the first character is not a number.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

If column E displays TRUE, that row is the first row of a particular address. This is because the first row of each address (where the street and number are) always begins with a number.

On the other hand, if column E shows FALSE, that particular row is the second row of an address (where the city, state and zip code appear) since those rows begin with alphabetic characters.

As a consequence of the above, you're ready to move to the second step of cleaning up the address data…

Step #2: How To Use The IF Function In Excel To Place Each Full Address In A Single Row Of The Excel Worksheet

This particular step doesn't focus on the functions and tools that are the main subject of this Excel tutorial. However, this step is important as it completes the process of putting each full address (which is originally divided in two rows) in a single row.

So let's go ahead and do this…

1. Step #1: Use The IF Function To Get The First Part Of Each Address.

More precisely, you're seeking to get the the street and number for each address.

The IF function allows you to check whether a condition is true or not and, based on the result, does one thing or another. Therefore, you can choose what the IF function should return if the condition is true or false.

For purposes of this tutorial, is important to understand its basic syntax: “IF(logical_test,value_if_true,value_if_false)”, where:

  • “logical_test” is the condition you want to test.
  • “value_if_true” is the value that the IF function returns if the condition you are testing is true.
  • “value_if_false” is the value that the IF function returns if the condition you are testing is false.

How can you use this to get the first part of each address?

The first thing you probably want to look at is column E, since this tells you which rows have the first part of each address. Those rows are the ones where column E shows TRUE since, in those cases, the first character is a number (and all addresses begin with a number).

Therefore, you can use the IF function to:

  • Test whether the value that appears in column E is equal to TRUE. This is the logical_test.
  • If the condition you are testing is true, which is the case if that particular row contains the first part of an address, print that first part of the address (the street and number which appear in column B).
  • If the condition you are testing is false, which happens if that row has the second part of an address, print nothing or leave the cell blank. This can be achieved by using quotes (“”).

How does this look in practice?

Let's go back to the Excel worksheet…

First, I add a new column. This is column F and is titled “First Part of Address”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The IF formula for cell F3 is “=IF(E3=TRUE,B3,””)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And, as expected, this returns the first part of the desired address.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can copy and paste this formula in all the relevant cells. Check out how, as planned, column F displays the first part of the address or is blank.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

2. Step #2: Use The IF Function To Get The Second Part Of The Address.

This time, you'll be using the IF function to get the city, state and zip code for each address.

This step is basically the same as above with a couple of small tweaks. In this case, you can use the IF function as follows:

  • Test whether column E shows TRUE. This is the same logical test used in the previous step.
  • If the condition is true, print the second part of the address (the city, state and zip code that is displayed in column B).

    Here is the main change in the syntax of the IF function when compared to the syntax used in the previous step. In the previous step you referred to the same row of the active cell whereas, now, you refer to one row below the active cell.

  • If the condition you are testing is false, print nothing or leave the cell blank. This is exactly the same result as in the previous step.

Let's start by adding an additional column to the Excel worksheet. This is column G and its title is “Second Part of Address”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The IF formula for cell G3 is “=IF(E3=TRUE,B4,””)”. Notice that this is exactly the same formula used in the previous step except for the second parameter which has changed from cell B3 (same row as active cell) to cell B4 (one row below the active cell).

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And, as planned, Excel returns the second part of the relevant address.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Just as in the previous step, you can copy and paste this formula to the 2,000 rows of column G. The results are substantially similar: Excel either returns the second part of the address or leaves the cell blank.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Step #3: How To Use Filters And Sorting To Delete Blank Rows In Excel Without Loosing Data

You may have noticed that, now that all addresses are in a single row, half of the cells in columns F and G are blank.

Those rows are no longer useful for purposes of fixing the addresses and, therefore, I show you how to delete them without loosing any data by using filters and sorting.

1. Step #1: Copy And Paste The Values Of All The Cells Located In Column G.

If you take a closer look at the IF formulas in column G, you'll notice that they always make reference to a cell located in the row immediately below. As a consequence of this, if you delete all the rows that have blanks, you also delete the cells to which these formulas make reference to. For example, cell G3 makes reference to cell B4, as shown in the image below:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Deleting these references without any previous preparations leads to invalid cell reference errors appearing in column G. For example, in the case above:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can avoid this type of error by copying all of column G and pasting its values.

To do this, proceed as follows. Below the step-by-step explanation there is an image illustrating how to perform all of these steps.

  • Step #1: Click on the column letter header G.
  • Step #2: In the Home tab of the Ribbon, click on “Copy”.
  • Step #3: In the same Home tab, click on the drop-down menu button below “Paste”.
  • Step #4: Once the drop-down menu expands, click on “Values”.
  • Step #5: Excel pastes hard-coded values (not formulas) on all cells of column G.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Once you have done this, the cells in column G won't have any formulas, just values. For example, in the case of cell G3:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

2. Step #2: Using Filters, Sort Column F Or G From Highest To Lowest.

I may explain filters in more depth in future tutorials. For the moment is enough to know that you can use the sorting and filtering tools of Excel for purposes of rearranging your data, as shown below.

To do this, proceed as follows. I include an image below the step-by-step explanation showing how you can do this in Excel.

  • Step #1: Select the headers of the table which, in this case, are located in row 2.
  • Step #2: Go to the Data tab of the Ribbon and click on “Filter”.
  • Step #3: Excel shows a drop-down arrow next to each header, showing that the filters are enabled but have not been applied.
  • Step #4: Click on the drop-down arrow to the right of “First Part of Address” in cell F2 or “Second Part of Address” in cell G2.
  • Step #5: When the full drop-down menu appears, click on “Sort Z to A”.
  • Step #6: Excel sorts all the columns of the table based on the values of the column whose drop-down menu you have used for sorting purposes.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Why have I asked to sort the data like this?

If you scroll down to the middle of the table, you notice that the rows whose columns F and G appear empty are all in the lower half of the table.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

This means that the 1,000 addresses are now all in the first 1,000 rows of the table and, therefore, you can proceed to eliminate rows 1,001 to 2,000.

3. Step #3: Delete Rows That Have Blank Cells In Columns F And G.

You can proceed as follows to delete all the rows that have blank cells in columns F and G. The image below the explanation illustrates all of these steps.

  • Step #1: Select all of the rows to be deleted. You can do this by, for example, clicking on the row number header of the first row to be deleted, and then using the keyboard shortcut “Shift + Ctrl + down arrow”. This may take you all the way to the end of the Excel worksheet; don't worry about it.
  • Step #2: Right click on the row number headers.
  • Step #3: A context menu appears.
  • Step #4: Click on “Delete”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Excel deletes all chosen rows. Now the table only has 1,000 rows, each corresponding to one of the 1,000 addresses.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

4. Step #4: Disable The Filters.

You can disable the filters by clicking on “Filter” in the Data tab.

This step is optional; you can also carry on with the rest of this Excel tutorial while having the filters enabled.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Step #4:How To Use The RIGHT Function In Excel To Determine Whether The Last Character In A Cell Is A Space

Before I begin this section, I have to make the following clarification:

Usually you won't use the method described in the following 3 steps (including steps #5 and #6) to deal with leading and trailing spaces in a text string. Instead of this, you'll generally use the TRIM function.

However, I believe carrying out all activities with the functions we're focusing on (LEFT, RIGHT, MID, LEN, FIND and SEARCH) gives you a better idea of the different things you can achieve with them.

Before we carry on, allow me to ask you the following question:

Based on the screenshot above, would you be able to say with certainty that there are no extra blank spaces at the end of an address?

For example, let's focus on the first address: 999 River Street.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Would you be able to say with certainty that the letter t in Street is the last character and there are no blank spaces after it?

It is a tough question to answer, isn't it?

And it is not a trivial question. As explained by John Walkenbach in Excel 2013 Formulas, extraneous spaces can cause problems in some cases, such as when using lookup formulas.

Fortunately, you can use the RIGHT function to take the guess work out of this.

The RIGHT function is, as you may expect, substantially similar to the LEFT function that I explained above. More precisely, the RIGHT function allows you to get the last (further to the right) characters in a text string. You decide, and tell Excel, how many characters it should return.

The syntax of the RIGHT function is, basically, the same as that of the LEFT function: “RIGHT(text,num_chars)”, where:

  • “text” is the text string from which you want to get the characters.This can be either the location of the text from which you want to extract the characters or a string within quotes (such as “I love Microsoft Excel”).
  • “num_chars” is the number of characters you want the RIGHT function to give you back.

    How many characters can you specify?As long as you don't specify a negative number (which is not allowed), you should be fine.

    Just note that, if you specify a number of characters that is larger than the length of the text string, the RIGHT function simply returns the whole string. Additionally, if you fail to specify a number, Excel assumes its 1 and return the last character of the string.

So let's go ahead and use the RIGHT function to determine whether any of the two parts of the addresses has a blank space at the end.

As in previous occasions, I start by adding two columns to the right of the Excel worksheet. These are columns H and I, and are named “Last Character of First Part” and “Last Character of Second Part” respectively.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The formula for cell H3 is “=RIGHT(F3,1)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And the formula for cell I3 is “=RIGHT(G3,1)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You'll notice that, according to the RIGHT function, the last character of the second part of the address is the number 2. This result was expected, as that is the last character of the zip code.

However, the cell with the last character of the first part shows nothing, meaning that it's not the letter t but rather a space.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can copy and paste these two formulas across all the rows of the table to see whether the other addresses have the same characteristic (the last character of their first part is a space).

As you can see in the results below, all of the cells in column H have no visible characters. They're all spaces.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Sigh…

This means that one of the next steps in the process is to eliminate the extra space at the end of the first part of each address.

Could you do it using some of the functions that you have already learned in this tutorial?

Yes!

You can, for example, use the LEFT function to grab all the characters of the first part of the address except for the last one. In the next two steps, I show you one of the ways this can be done.

There are other ways to achieve this goal such as, for example, using the TRIM function. However, this is a topic that I'll cover some other time.

Step #5: How To Use The LEN Function In Excel To Calculate The Number Of Characters In A Text String

Do you recall the syntax of the LEFT function?

That's right, it's “LEFT(text,num_chars)”.

If your purpose is to extract all the characters from the first part of the address except for the last one, the first question you may have is: how can you figure what is the character length of each of those strings of text?

That is a reasonable question. After all, the length of each address varies.

In this section, I introduce you a function that allows you to count the number of characters in a text string: the LEN function.

The LEN function counts and informs you what is the number of characters in a string. In other words, it tells you how long the text string is. The syntax of LEN is “LEN(text)”, where “text” is simply the string whose length you want to know.

Note that spaces, such as the ones that appear at the end of the first part of the addresses in the sample data set or between words, are also counted as characters.

As explained by Ken Bluttman in Excel Formulas and Functions for Dummies, LEN is usually used in conjunction with other functions such as LEFT, RIGHT or MID. In those cases, LEN is regularly used to set one of the parameters of the other function. I may explain in future tutorials how you can do this to create even more powerful Excel text formulas.

Before using the LEN function to calculate the number of characters in the first part of each address, I insert a new column in the Excel worksheet. This is column J and is named “Length of First Part of Address”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Now you can proceed to measure the length of the first part of each address by using the LEN function. For example, the formula for cell J3 is “=LEN(F3)”

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And LEN returns the number of characters in the first part of the address.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can then, as usual, copy and paste the formula in all the relevant cells of column J to get Excel to calculate the length of the first part of each address.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Now that you have the length of the first part of each address, you can simply subtract one from each number to get the number of characters that you should extract from each string of text (using the LEFT function) to eliminate the extra space at the end.

For these purposes, I simply add a new column to the Excel worksheet (column J, titled “Proper Length of First Part of Address”) where I subtract 1 from the values obtained above.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

After copying and pasting this formula in all the appropriate cells, the table looks roughly as follows:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Step #6: How To Use The LEFT Function To Get All The Characters In A Text String Except The Last One

By now, you have learned how to use the LEFT function in Excel and you know how many characters you need to extract from the first part of each address in order to exclude the last character.

So… do you know how to use the LEFT function to get all the characters, excluding the last one, in the first part of an address?

Let's go through this process together…

First, I add a new column to the address table. This is column L and its title is “Proper First Part of Address”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You already know the syntax of the LEFT function. For example, the formula for cell L3 is “=LEFT(F3,K3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And Excel returns the first part of the address, excluding the last character. In this case, this means that the text string doesn't have the extra space at the end.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can then copy and paste it for all the rows in the table.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

For organizational purposes, I add a new column to the table (column M with the title “Second Part of Address”), where I put the second part of each address. This way, the first and second part of the address are next to each other.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Step #7: How To Use The FIND And SEARCH Functions In Excel

Things are looking good, aren’t they?

Each address is in a single row and there are no extra spaces or extraneous characters.

However, the final objective of the example has not yet been achieved. I said at the beginning of this Excel tutorial that I'd show you how to fill out the following table using Excel text formulas:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

In order to do this, I need to be able to extract each of these elements from the two parts of the addresses that currently appear in columns L and M.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

As you probably imagine, it is possible to:

  • Use functions such as LEFT and RIGHT to get the desired parts of each text string.
  • Use LEN to calculate the number of characters to be extracted by the LEFT and RIGHT functions.

However, in this particular case, the situation is slightly more complicated than when using the LEFT and LEN functions to get the first part of the address without the last character.

The reason for this is that:

  • In the previous steps, the length of the whole text string varied, but the number of characters to be excluded was fixed (it was always 1).
  • Now, both the length of the text string and the length of the components to be included or excluded varies.For example, street addresses (both the street and the number) and city names have different lengths.State names have all the same length (2 characters) but, in order to be able to extract them using Excel text formulas (more precisely, using the MID function which I explain below), it's necessary to know the position of the first character which, in turn, depends on the city name length.

    Zip codes are more manageable. They are all 5 characters long and sit at the end of the string. Therefore, as you may have guessed, it is possible to extract them with the RIGHT function.

In any case, it's necessary to find a way to measure the length of each of the different elements of the addresses.

How could you do this?

Allow me to introduce the FIND and SEARCH functions…

The FIND And SEARCH Functions In Excel

The FIND and SEARCH functions in Excel are substantially similar. Their purpose, as you may imagine from their names, is to find a particular piece of text within a text string.

What does this mean?

Let's look at the rough idea graphically. Assume you are reading a book and you see the following text:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Now, imagine that you want to find the string of text “state Department”.

If you had the possibility to use the FIND or SEARCH functions of Excel, you could tell them something like: find the text string “state Department” within this page.

And Excel would tell you the location of the string “state Department”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Now that you know the basic idea behind the FIND and SEARCH functions in Excel, let's take a closer look at how they work in practice. From the explanation above, it is already clear that the main purpose of both FIND and SEARCH is to locate a particular text string within a longer text string.

How does Excel tell you the location of the text string you want to locate?

The FIND and SEARCH functions tell you where is the string you are searching for by returning a number that represents the starting position of that text string. Let's take, for example, the first address in the sample data set: 999 River Street and assume you want to know the location of the word “River”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

In this case, Excel returns the number 5 because the starting position of the word “River” is the fifth character. The first 4 characters are 9, 9, 9 and space.

Let's take a look now at the syntax of the FIND and SEARCH functions in Excel. The syntax of FIND is “FIND(find_text,within_text,start_num)” whereas the syntax of SEARCH is “SEARCH(find_text,within_text,start_num)”. In both cases:

  • “find_text” is the string that you want to find. In the cases above, it is “state Department” or “River”.
  • “within_text” is the text string where you want to search. In the cases above, it is the whole page or the Proper First Part of Address in the sample Excel worksheet.
  • “start_num” is the character at which you want to start to search for the find_text within the within_text.This argument is optional. If you leave it blank, Excel assumes it is 1 and begins the search on the first character of the within_text.start_num is useful if, for example, you are only interested in the find_text that appears towards the end of a particular string of text.For example, in the case of 999 River Street above, you may want to find the location of the second space (the one that separates the words “River” and “Street” but are not interested in knowing where the first space (that separates 999 from River) is. In such a case, you can set start_num to a number such as 6 (which, as explained above, is the starting position of the word “River”) and the FIND or SEARCH function return the number 10.

    In fact, if you continue reading, you'll notice that this is precisely one of the methods that I use below.

You probably have an additional question regarding the FIND and SEARCH functions…

Are FIND and SEARCH then the same function? Is there any difference between them?

Good question. There are, indeed, a couple of differences between FIND and SEARCH. The main ones are the following:

  • FIND is case-sensitive whereas SEARCH is not.For example, using the text from the cases above, FIND distinguishes between “state Department” and “state department” or between “River” and “river”. The SEARCH function doesn't make such a distinction.
  • SEARCH allows you to use the wildcard characters “?” (question mark) and “*” (asterisk) in find_text (the text you are searching for), whereas FIND does not.

    What is the purpose of these wildcard characters?The question mark (?) character matches any single character. For example, in the case of 999 River Street above; if instead of searching for “River” you search for “R?ver”, Excel also searches for variants such as “Rover”.

    The asterisk (*) character matches any sequence of characters. Continuing with the case of 999 River Street; if instead of searching for “River” you type in “Riv*”, Excel also looks out for different words that begin with “Riv” such as “Riviera”.

    What should you do if you want to actually search for a question mark (?) or asterisk (*)?Type a tilde “~” before the question mark or asterisk. For example, if you want to search for “River?”, type “River~?” and if you want to search for “River*”, type “River~*”.

    And… what should you do if you want to search for a tilde (~)?

    Following with the logic of adding tildes before the special characters, in this case you need to type 2 tildes (~~).

Now you that you have a good understanding of both the FIND and SEARCH functions, let's take a look at…

How To Apply The FIND Or SEARCH Functions To The Sample Data Set

The main purpose of introducing the FIND and SEARCH functions to you is to allow you to measure the length of each of the different elements of the addresses so that, in the following steps, you can get each individual item using the LEFT, RIGHT and MID functions.

Below, I explain to you how to do this.

Please note that I use and make reference to the SEARCH function. Theoretically, for this particular case, you can also use the FIND function since the searches do not use wildcard characters and there are no lowercase nor uppercase letters.

1. Step #1: Use The SEARCH Function To Locate Spaces And Commas.

Use SEARCH to find the location of:

  • The first space in the first part of the address. This is the space that separates the street name from the number.For example, in the case of the first address:

    Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

  • The comma (,) in the second part of the address. This is the space that separates the city from the state.For example, using the same case as above:

    Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

  • The last space in the second part of the address. This is the space that separates the state from the zip code.Continuing with the same example:

    Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

For clarity purposes, I add three new columns to the table. These columns are N, O and P. Their titles are “Location of First Space in First Part”, “Location of “,” in Second Part” and “Location of Last Space in Second Part”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The formulas for the first two columns are relatively straightforward. After all, you know what is the text you are searching for (a space or a comma), what is the text you are searching in, and that you are searching from the beginning of the text.

Therefore, the formula for cell N3 is “=SEARCH(” “,L3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Similarly, the formula in cell O3 is “=SEARCH(“,”,M3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Both formulas return the expected results. For example, the location of the first space in the first part of the address is 4 (the first 3 characters are 9, 9 and 9) and the location of the comma in the second part is 7 (the first 6 characters are E, a, s, t, o and n).

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The syntax of the third SEARCH formula, whose purpose is to find the last space in the second part of the address, is slightly more complicated.

If you take a close look at the second part of each address, you'll notice that there are at least two spaces: one after the comma (,) that separates the city from the state, and one that separates the state from the zip code. There may be additional spaces if the city name is two words or longer.

You want the SEARCH function to return the location of the last space. This means that you need to specify a third parameter in the SEARCH function: the optional start_num argument which specifies the character at which you want to begin the search.

This is, however, not that simple. After all, city names have different lengths so you can't just fix start_num.

To solve this small issue, let's add a couple of intermediate steps.

First, I add an extra column in the Excel worksheet between the current columns O (Location of “,” in Second Part) and P (Location of Last Space in Second Part). This new column has the name “Beginning of State” and, as you see later, it comes in handy for other purposes in addition to finding the location of the last space in the second part of the address.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

How do you know the number of the character at which the state begins?

You already know what is the number of the character at which the comma (,) that separates the city from the state is. This is the value that appears in column O (Location of “,” in Second Part).

Additionally, if you look closely at the format of the second part of all addresses, you'll notice that after the comma there is a space (which is the first space in the second part). The state begins after that space.

As you have probably realized by now, the state begins 2 positions after the comma. Therefore, to find the number of the character at which the state begins you just need to add 2 to the value that appears in column O.

For example, the formula for cell P3 is “=O3+2”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Once you know the position at which the state begins, you know that the next space is the last space in the second part of the address.

Therefore, you can use the position of the first character of the state as the starting point for the search of the last space in the text string (the start_num argument).

Considering the above, you can build a slightly more complex SEARCH function to find this last space. For example, the formula for cell Q3 is “=SEARCH(” “,M3,P3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

The newly added columns return the values that were expected so you can copy and paste the formulas in all the cells of columns N, O, P and Q to get all the relevant locations for each address.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

2. Step #2: Determine Length Of Components Of First Part Of Address.

Use the data you have already calculated to determine the length of the different components in the first part of the address: namely the street name and number.

If you go back to column K of the Excel worksheet, you find the total length of the first part of the address after excluding the extra space at the end.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Additionally, in the step immediately prior to this one, you found the location of the space that separates the number and the street name. This value appears in column N of the Excel worksheet.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Using these two values, you can determine:

  • The length of the number in the first part of the address.You can find this by subtracting 1 from the location of the first space. This makes sense, since that space is just (1 character) after the end of the number
  • The length of the street name.

    You can calculate this by subtracting the location of the first space from the length of the whole text string. This makes sense, since that space is immediately (1 character) before the beginning of the street name.

Let's do this…

For clarity purposes, I add (again) two new columns to the table in the Excel worksheet. These are columns R and S. Their titles are “Length of No.” and “Length of Street Name”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And then I type in the relevant formulas. For example, the formula for cell R3 is “=N3-1”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And the formula for cell S3 is “=K3-N3”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

As usual, you can simply copy and paste these formulas in the rest of the cells of those two columns to get the lengths of the street names and numbers for the rest of the addresses.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

3. Step #3: Determine The Length Of The City Name.

You may wonder…

Wait! What happens with the length of the state and zip code? Don't we need to calculate those too?

You can calculate the length of the states and zip codes for practicing purposes. However, this is not strictly necessary because they are always the same. More precisely:

  • States are always 2 characters long.
  • Zip codes are always 5 characters long.

So in reality, it's only necessary to calculate the length of the city name.

Do you know how to do this calculation?

Hint: it's very similar to the way we calculated the length of the number in the first part of the address.

Before you answer, let me add a new column to the Excel worksheet. This is column T and I name it “Length of City”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You may have answered that the calculation of the length of any city name requires that you subtract 1 from the location of the comma in the second part of the address.

If this was your answer, you are correct! This makes sense due to the fact that the comma is immediately (1 character) after the end of the city.

Therefore, for example, the formula for cell T3 is “=O3-1”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can then proceed to copy and paste this formula in all the other rows of the table to have Excel calculate the length of each city name.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Step #8: How To Use The LEFT, RIGHT And MID Functions In Excel To Get The Individual Components Of Each Address

I am aware that this has been a long tutorial…

But you're close to finishing.

This is the step, where you actually extract each of the components of each address to the table where each of them has its own column.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

You can do most of this by using the LEFT and RIGHT functions which have been explained in this Excel tutorial. You, however, need to use the MID function to get the State data.

So, before going into the actual process of getting the data, let's take a look at the MID function…

The MID Function In Excel

The MID function works similarly to the LEFT and RIGHT functions.

In particular, its purpose is substantially the same: to grab a certain amount of characters from a text string.

Why do you need the MID function if you already know how to use the LEFT and RIGHT functions?

You already know that you can use the LEFT function to get the first (furthest to the left) characters of a piece of text and the RIGHT function to extract the last (furthest to the right) characters of a string.

But… how can you get characters from the middle of a text string?

For example, in the case of the address database that has been used as an example in this Excel tutorial, how can you get the state data?

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Theoretically, you can first apply the LEFT function to get the left portion of the address (up to and including the state) and, then, the RIGHT function to get the state. You can also do it the other way around: apply the RIGHT function followed by the LEFT function…

But using the MID function is simpler and doesn’t require you to go through multiple steps.

More precisely, the MID function returns a certain number of characters from the middle of a piece of text. It does this by starting at whichever position you specify in the formula and grabbing the amount of characters you determine.

The syntax of the MID function is “MID(text,start_num,num_chars)”, where:

  • “text” is the string from which you want to get the characters.
  • “start_num” is the position of the first character you want the MID function to get.start_num can't be a negative number.Ideally, it should also be less than the length of the text from which the MID function is extracting the characters. The reason for this is that, if start_num is larger than the length of the text, the result returned by the formula is “” (empty).

    Finally, as suggested by Ken Bluttman in Excel Formulas and Functions for Dummies, start_num should be a number larger than one. Why is this? Because, if you needed to begin to extract text from the beginning of the string, you could simply use the LEFT function.

  • “num_chars” is the number of characters, or length, of the text string you want the MID function to return. This value can't be a negative number.

If, for some reason, start_num (position of first character to be extracted) plus num_chars (number of characters to be grabbed) is more than the length of the text string from which the function is getting the characters, the MID function returns all the characters up to the end of the text. In this case, it has a similar effect to applying RIGHT (although the syntax is certainly different).

How To Use The LEFT, RIGHT And MID Functions To Get The Individual Components Of Each Address

By now you know how to use the LEFT, RIGHT and MID functions in Excel. You have also applied the LEFT and RIGHT functions to a couple of different situations.

So let's go ahead and apply them to get the individual components of each address and fill the following table:

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

For ease of reference, I add the columns above to the left of the table in the original Excel worksheet. They are columns U through Z.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

1. Step #1: Use The LEFT Function To Fill The “No.” Fields.

You know the text from which you want to extract the data (column L; Proper First Part of Address) and how many characters to get (column R; Length of No.).

You can build the relevant LEFT function with these two arguments. For example, the formula for cell V3 is “=LEFT(L3,R3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Notice that the value returned by the LEFT function for the first address (999 River Street) is as expected (999).

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

2. Step #2: Use The RIGHT Function To Fill The Street Fields.

The text from which you want to get the data is the same as above (column L). In this case, the amount of characters to get appears in column S (Length of Street Name).

These two parameters are all you need to build the relevant RIGHT formula. For example, in the case of cell U3, the relevant formula is “=RIGHT(L3,S3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Just as in the previous case, the text returned by the RIGHT function for the first address is the correct one (River Street).

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

3. Step #3: Fill The City By Using The LEFT Function.

The city is the first item in the second part of the address. Therefore, in this case, the string from which you want to extract the data is column M (Second Part of Address). The amount of characters to get is in column T (Length of City).

You are now ready to insert the LEFT formula. As an example, for cell W3, the formula is “=LEFT(M3,T3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Once again, the formula returns the appropriate data (Easton).

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

4. Step #4: Use The MID Function To Get The Data For The State Fields.

Finally!

The chance for you to test the MID function.

Let's recall the syntax of the MID function: “MID(text,start_num,num_chars)” and analyze each item separately:

  • The string from which you want to extract the characters is the same as that from which you have gotten the city. Therefore, in the first argument, you make reference to column M.
  • Maybe you remember that, when explaining how to use the FIND and SEARCH functions in Excel, I added column P (Beginning of State) and calculated what was the location of the first character of the state.I also mentioned that this value would be useful later… and here it is the moment where you get to use it again.You know that the position of the first character you want the MID function to get is in this column P. Therefore, you have the second argument for the formula.
  • Finally, you know that the states are always 2 characters long.

Therefore, you are ready to insert the appropriate MID formula. For example, in cell X3, this is “=MID(M3,P3,2)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And Excel returns the correct values.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

5. Step #5: Use The RIGHT Function To Obtain The Zip Code Data.

The zip code is the last item to extract.

As anticipated above, you are using the RIGHT function to extract the zip code.

The text from which you extract the data is the same as in the two cases above (column M). All zip codes are 5 characters long. This is all the data you need to create the relevant RIGHT function.

For example, for cell Y3, the formula is “=RIGHT(M3,5)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And you get the correct zip code as a result.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

6. Step #6: Copy And Paste Formulas.

Copy and paste all the formulas in cells U through Y all the way down to the end of the table.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Congratulations!

You have completed all the steps of this Excel Text Formulas Tutorial that are related to how to use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions in Excel.

Additionally, your table is almost complete…

If you have the energy for a final step, I show you how to fill the last column of the table above…

Step #9: How To Use The CONCATENATE Function In Excel To Join All The Components Of An Address In A Single Cell

For the moment, you just need to know that the CONCATENATE function allows you to join different text strings into a single one. In this particular case, you use it to join the different components of each address, which you extracted in the step before, into a single cell.

The syntax of the CONCATENATE function is relatively simple: “CONCATENATE(text1,text2,…)”. In other words, the arguments of the CONCATENATE function are simply the text strings you want to join. As shown below, these arguments can also be strings (such as spaces or punctuation marks) surrounded by quotation marks (“”).

This is not too complicated, right?

So let's go ahead and join all the components of an address in a single cell using the CONCATENATE function.

The form of the final joined addresses is “Street Name ###, City, State Zip Code”. This means that the first address should be River Street 999, Easton, PA 18042.

So how does the formula for this look like?

As you are probably aware, most of the text strings that are joined are in the last few columns (columns U through Y) of the table. These are the columns where the individual items of each address are stored.

However, you need to add spaces ( ) and commas (,). You can do this by using quotation marks (“”).

For example, the formula for cell Z3 is “=CONCATENATE(U3,” “,V3,”, “,W3,”, “,X3,” “,Y3)”.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

And Excel returns the expected address.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Copy and paste this formula in all the rows of column Z and you are completely done.

Really!

The table is ready.

Which is the best formula to return just the 5 characters on the left hand side of the text in cell?

Conclusion

Once again…

Congratulations! You are ready to start using the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions in Excel.

This Excel Text Functions Tutorial is accompanied by Excel workbooks containing the data and formulas I use above. You can get immediate free access to these example workbooks by subscribing to the Power Spreadsheets Newsletter.

I hope you agree that, despite their relative simplicity, these text functions are very powerful and useful. They are (usually) considered to be among the Excel functions everyone should know due to, among others, how much easier they make life when you are isolating pieces of text or cleaning up large data sets.

If you have completed this tutorial about Excel text formulas, you:

  • Have a basic understanding of when you can use the LEFT, RIGHT, MID, LEN, FIND and SEARCH functions in Excel, and what these functions are capable of doing.
  • Know the syntax of these formulas in order to be able to apply them in different situations.

You also have a basic understanding of some other functions and tools of Excel, such as the VALUE, ISNUMBER, IF and CONCATENATE functions, filters and sorting commands. I may cover these particular topics in more detail in future Excel tutorials but, using the information included in this guide, you can also start using them immediately.

There are other topics and methods you can learn for purposes of improving your efficiency and productivity when cleaning up data or carrying out similar activities with Excel that I have not covered in this guide. As I mentioned at the beginning of this tutorial about Excel text formulas, there are other methods that can be used to clean up the addresses that appear in the example that I used here.

Books Referenced In This Excel Tutorial

  • Bluttman, Ken (2013). Excel Formulas and Functions For Dummies. Indianapolis, IN: John Wiley & Sons Inc.
  • Walkenbach, John (2013). Excel 2013 Bible. Indianapolis, IN: John Wiley & Sons Inc.
  • Walkenbach, John (2013). Excel 2013 Formulas. Hoboken, NJ: John Wiley & Sons Inc.