The #NUM! error occurs in Excel formulas when a calculation can’t be performed. For example, if you try to calculate the square root of a negative number, you’ll see the #NUM! error.error is a matter of adjusting inputs as required to make a calculation possible again.
Contents
- 1 Is Num a function in MS Excel?
- 2 What does start NUM mean in Excel?
- 3 Is #value Excel?
- 4 What is Iferror?
- 5 How do I find a number in a cell in Excel?
- 6 What is an Xlookup in Excel?
- 7 How do I replace NUM in Excel with 0?
- 8 How do I convert to numbers in Excel?
- 9 Is cell empty Excel?
- 10 How does a VLOOKUP work?
- 11 What is the syntax of VLOOKUP?
- 12 What is index on Excel?
- 13 How do you use VLOOKUP and Iferror?
- 14 How do I return 0 if error?
- 15 How do I count the number of text in Excel?
- 16 Is Xlookup faster than VLOOKUP?
- 17 What is Xlookup vs VLOOKUP?
- 18 What is Excel Lambda?
- 19 How do you use ISNA?
- 20 How do I fix #value in Excel?
Is Num a function in MS Excel?
The Excel ISNUMBER function returns TRUE when a cell contains a number, and FALSE if not. You can use ISNUMBER to check that a cell contains a numeric value, or that the result of another function is a number.
What does start NUM mean in Excel?
Start_num Optional. Specifies the character at which to start the search. The first character in within_text is character number 1. If you omit start_num, it is assumed to be 1.
Is #value Excel?
The #VALUE! error appears when a value is not the expected type. This can occur when cells are left blank, when a function that is expecting a number is given a text value, and when dates are treated as text by Excel.
What is Iferror?
IFERROR returns a value you specify if a formula evaluates to an error; otherwise, it returns the result of the formula.
How do I find a number in a cell in Excel?
Use the COUNT function to get the number of entries in a number field that is in a range or array of numbers. For example, you can enter the following formula to count the numbers in the range A1:A20: =COUNT(A1:A20). In this example, if five of the cells in the range contain numbers, the result is 5.
What is an Xlookup in Excel?
Use the XLOOKUP function to find things in a table or range by row.With XLOOKUP, you can look in one column for a search term, and return a result from the same row in another column, regardless of which side the return column is on.
How do I replace NUM in Excel with 0?
Step 1: Select the range that you will work with. Step 2: Press the F5 key to open the Go To dialog box. Step 3: Click the Special button, and it opens the Go to Special dialog box. Step 6: Now just enter 0 or any other value that you need to replace the errors, and press Ctrl + Enter keys.
How do I convert to numbers in Excel?
Convert Text to Numbers Using ‘Convert to Number’ Option
- Select all the cells that you want to convert from text to numbers.
- Click on the yellow diamond shape icon that appears at the top right. From the menu that appears, select ‘Convert to Number’ option.
Is cell empty Excel?
The Excel ISBLANK function returns TRUE when a cell is empty, and FALSE when a cell is not empty. For example, if A1 contains “apple”, ISBLANK(A1) returns FALSE. value – The value to check.
How does a VLOOKUP work?
The VLOOKUP function performs a vertical lookup by searching for a value in the first column of a table and returning the value in the same row in the index_number position.As a worksheet function, the VLOOKUP function can be entered as part of a formula in a cell of a worksheet.
What is the syntax of VLOOKUP?
In its simplest form, the VLOOKUP function says: =VLOOKUP(What you want to look up, where you want to look for it, the column number in the range containing the value to return, return an Approximate or Exact match – indicated as 1/TRUE, or 0/FALSE).
What is index on Excel?
Summary. The Excel INDEX function returns the value at a given location in a range or array. You can use INDEX to retrieve individual values, or entire rows and columns. The MATCH function is often used together with INDEX to provide row and column numbers.
How do you use VLOOKUP and Iferror?
The formula works with the following logic: If the first VLOOKUP does not find anything, the first IFERROR traps an error and runs another VLOOKUP. If the second VLOOKUP fails, the second IFERROR catches an error and runs the third VLOOKUP, and so on. If all Vlookups stumble, the last IFERROR returns your message.
How do I return 0 if error?
You can also suppress this error by nesting your division operation inside the IFERROR function. Again, using A2/A3, you can use =IFERROR(A2/A3,0). This tells Excel if your formula evaluates to an error, then return 0, otherwise return the result of the formula.
How do I count the number of text in Excel?
How to Count Text in Excel
- If you want to learn how to count text in Excel, you need to use function COUNTIF with the criteria defined using wildcard *, with the formula: =COUNTIF(range;”*”) .
- Text Cells can be easily found in Excel using COUNTIF or COUNTIFS functions.
Is Xlookup faster than VLOOKUP?
Compared to a normal VLOOKUP, the binary XLOOKUP is significantly faster. But a VLOOKUP with a approximate match is still a little bit faster. The binary XLOOKUP is slightly slower than an approximate VLOOKUP (~16% slower).
What is Xlookup vs VLOOKUP?
XLOOKUP requires referencing fewer cells. VLOOKUP required you to input an entire data set, but XLOOKUP only requires you to reference the relevant columns or rows. By referencing fewer cells, the XLOOKUP will increase your spreadsheet calculation speed and potentially result in fewer circular reference errors.
What is Excel Lambda?
The Excel LAMBDA function provides a way create custom functions that can be reused throughout a workbook, without VBA or macros. Create custom function. As defined by formula. =LAMBDA (parameter,, calculation) parameter – An input value for the function.
How do you use ISNA?
The Excel ISNA function returns TRUE when a cell contains the #N/A error and FALSE for any other value, or any other error type. You can use the ISNA function with the IF function test for #N/A and display a friendly message if the error occurs. value – The value to check if #N/A.
How do I fix #value in Excel?
Remove spaces that cause #VALUE!
- Select referenced cells. Find cells that your formula is referencing and select them.
- Find and replace.
- Replace spaces with nothing.
- Replace or Replace all.
- Turn on the filter.
- Set the filter.
- Select any unnamed checkboxes.
- Select blank cells, and delete.
Содержание
- What Is Num In Excel?
- Is Num a function in MS Excel?
- What does start NUM mean in Excel?
- Is #value Excel?
- What is Iferror?
- How do I find a number in a cell in Excel?
- What is an Xlookup in Excel?
- How do I replace NUM in Excel with 0?
- How do I convert to numbers in Excel?
- Is cell empty Excel?
- How does a VLOOKUP work?
- What is the syntax of VLOOKUP?
- What is index on Excel?
- How do you use VLOOKUP and Iferror?
- How do I return 0 if error?
- How do I count the number of text in Excel?
- Is Xlookup faster than VLOOKUP?
- What is Xlookup vs VLOOKUP?
- What is Excel Lambda?
- How do you use ISNA?
- How do I fix #value in Excel?
- #NUM! Error In Excel – How To Fix
- What is a #NUM! Error in Excel?
- Why Does it Appear?
- Examples
- 1. Fixing #NUM! error when the calculation is impossible
- 2. Fixing #NUM! error when the number is too large or small
- 3. Fixing #NUM! error resulting from an iteration formula
- 4. Fixing #NUM! error when you’ve entered an incorrect function argument
- Subscribe and be a part of our 15,000+ member family!
What Is Num In Excel?
The #NUM! error occurs in Excel formulas when a calculation can’t be performed. For example, if you try to calculate the square root of a negative number, you’ll see the #NUM! error.error is a matter of adjusting inputs as required to make a calculation possible again.
Is Num a function in MS Excel?
The Excel ISNUMBER function returns TRUE when a cell contains a number, and FALSE if not. You can use ISNUMBER to check that a cell contains a numeric value, or that the result of another function is a number.
What does start NUM mean in Excel?
Start_num Optional. Specifies the character at which to start the search. The first character in within_text is character number 1. If you omit start_num, it is assumed to be 1.
Is #value Excel?
The #VALUE! error appears when a value is not the expected type. This can occur when cells are left blank, when a function that is expecting a number is given a text value, and when dates are treated as text by Excel.
What is Iferror?
IFERROR returns a value you specify if a formula evaluates to an error; otherwise, it returns the result of the formula.
How do I find a number in a cell in Excel?
Use the COUNT function to get the number of entries in a number field that is in a range or array of numbers. For example, you can enter the following formula to count the numbers in the range A1:A20: =COUNT(A1:A20). In this example, if five of the cells in the range contain numbers, the result is 5.
What is an Xlookup in Excel?
Use the XLOOKUP function to find things in a table or range by row.With XLOOKUP, you can look in one column for a search term, and return a result from the same row in another column, regardless of which side the return column is on.
How do I replace NUM in Excel with 0?
Step 1: Select the range that you will work with. Step 2: Press the F5 key to open the Go To dialog box. Step 3: Click the Special button, and it opens the Go to Special dialog box. Step 6: Now just enter 0 or any other value that you need to replace the errors, and press Ctrl + Enter keys.
How do I convert to numbers in Excel?
Convert Text to Numbers Using ‘Convert to Number’ Option
- Select all the cells that you want to convert from text to numbers.
- Click on the yellow diamond shape icon that appears at the top right. From the menu that appears, select ‘Convert to Number’ option.
Is cell empty Excel?
The Excel ISBLANK function returns TRUE when a cell is empty, and FALSE when a cell is not empty. For example, if A1 contains “apple”, ISBLANK(A1) returns FALSE. value – The value to check.
How does a VLOOKUP work?
The VLOOKUP function performs a vertical lookup by searching for a value in the first column of a table and returning the value in the same row in the index_number position.As a worksheet function, the VLOOKUP function can be entered as part of a formula in a cell of a worksheet.
What is the syntax of VLOOKUP?
In its simplest form, the VLOOKUP function says: =VLOOKUP(What you want to look up, where you want to look for it, the column number in the range containing the value to return, return an Approximate or Exact match – indicated as 1/TRUE, or 0/FALSE).
What is index on Excel?
Summary. The Excel INDEX function returns the value at a given location in a range or array. You can use INDEX to retrieve individual values, or entire rows and columns. The MATCH function is often used together with INDEX to provide row and column numbers.
How do you use VLOOKUP and Iferror?
The formula works with the following logic: If the first VLOOKUP does not find anything, the first IFERROR traps an error and runs another VLOOKUP. If the second VLOOKUP fails, the second IFERROR catches an error and runs the third VLOOKUP, and so on. If all Vlookups stumble, the last IFERROR returns your message.
How do I return 0 if error?
You can also suppress this error by nesting your division operation inside the IFERROR function. Again, using A2/A3, you can use =IFERROR(A2/A3,0). This tells Excel if your formula evaluates to an error, then return 0, otherwise return the result of the formula.
How do I count the number of text in Excel?
How to Count Text in Excel
- If you want to learn how to count text in Excel, you need to use function COUNTIF with the criteria defined using wildcard *, with the formula: =COUNTIF(range;”*”) .
- Text Cells can be easily found in Excel using COUNTIF or COUNTIFS functions.
Is Xlookup faster than VLOOKUP?
Compared to a normal VLOOKUP, the binary XLOOKUP is significantly faster. But a VLOOKUP with a approximate match is still a little bit faster. The binary XLOOKUP is slightly slower than an approximate VLOOKUP (
What is Xlookup vs VLOOKUP?
XLOOKUP requires referencing fewer cells. VLOOKUP required you to input an entire data set, but XLOOKUP only requires you to reference the relevant columns or rows. By referencing fewer cells, the XLOOKUP will increase your spreadsheet calculation speed and potentially result in fewer circular reference errors.
What is Excel Lambda?
The Excel LAMBDA function provides a way create custom functions that can be reused throughout a workbook, without VBA or macros. Create custom function. As defined by formula. =LAMBDA (parameter,, calculation) parameter – An input value for the function.
How do you use ISNA?
The Excel ISNA function returns TRUE when a cell contains the #N/A error and FALSE for any other value, or any other error type. You can use the ISNA function with the IF function test for #N/A and display a friendly message if the error occurs. value – The value to check if #N/A.
How do I fix #value in Excel?
Remove spaces that cause #VALUE!
- Select referenced cells. Find cells that your formula is referencing and select them.
- Find and replace.
- Replace spaces with nothing.
- Replace or Replace all.
- Turn on the filter.
- Set the filter.
- Select any unnamed checkboxes.
- Select blank cells, and delete.
Источник
#NUM! Error In Excel – How To Fix
The #NUM! error is a frequent visitor on your worksheet. This can make you want to pull your hair out if you’ve used the output cell as a reference in another formula.
Looking for a fix? ExcelTrick has it for you.
Table of Contents
What is a #NUM! Error in Excel?
#NUM! error occurs when you’ve entered a formula in your worksheet, but it can’t perform the calculation. For instance, say you’re trying to find square roots for a list of numbers. But there’s a negative value in the list. The formula will return a #NUM error for this value since it’s impossible to find the square root of a negative number.
But that’s not the only reason that can invite a #NUM! error into your worksheet. There are four possibilities that could be the reason for your perils. Fixing the error typically requires adjusting the values (no, it’s not mechanical, but an arithmetic error), and you’ll be set in no time.
Why Does it Appear?
So, why do #NUM! errors occur? Yes, as mentioned, there are four reasons. Let’s talk about them in a little more detail.
We already talked about the first reason in the previous section. If you’re trying to perform an impossible calculation, for instance, finding the square root of a negative number, you’ll get a #NUM! error.
The second reason could be that the output is too large or too small. The smallest and largest numbers that Excel can handle are -1*10^308 and 1*10^308, respectively. Excel displays any output outside this range as a #NUM! error.
The third reason could be that you’ve used an iterative formula that’s not finding a result. For instance, if you’re doing some capital budgeting and you’ve used the IRR formula in the process, and you see a #NUM! error, check the IRR formula. The IRR formula tries to calculate an answer that’s accurate down to 0.00001%. It tries to run about 20 iterations to find the answer. If it doesn’t, it returns the #NUM! error.
The fourth reason could be that you’ve entered an argument incorrectly in your function. For instance, think about the DATEDIF function. Things are all smooth sailing with this delightfully simple function, unless you mistakenly enter a start date that falls after the end date.
Sounds good? Perfect, let’s now try to look at how each of these reasons could play out on your worksheet and how to fix them with examples.
Examples
Following are some examples of when you’d see a #NUM! error.
1. Fixing #NUM! error when the calculation is impossible
When you’ve inadvertently asked Excel to perform an impossible calculation, you’ll see a #NUM! error. But the fix is, well, to make the calculation possible.
Let’s use the square root problem we discussed earlier. Say you’ve got some numbers in a list that you want a square root of, and you’ve applied the following formula to the numbers.
A negative number has sneaked into your list and caused a #NUM! error on your other spotless spreadsheet.
Once you’ve calmed yourself down from the panic of seeing the #NUM! error, think rationally. Since it’s impossible to find the square root of a negative number, you need to make it positive. The way to make it positive? The ABS function.
Here’s the formula you should use to fix the #NUM! error.
The ABS function converts the negative value into a positive one. When you enter a positive value into the SQRT function, everything should work fine. Easy-peasy, eh?
2. Fixing #NUM! error when the number is too large or small
The thing is… you can’t really fix this. If your output is too large or small for Excel, you’ll need to change your input to bring the output value within the acceptable range. For instance, say you’ve performed the following arithmetic operation in your Excel sheet:
Now, there’s no chance that Excel will be able to display this value, and will therefore return a #NUM! error. There’s no way to display the result, so you’ll need to change the output.
3. Fixing #NUM! error resulting from an iteration formula
Functions like IRR can sometimes also lead to a #NUM error. Such errors are mainly because of two reasons:
- The specified Cash flow does not contain at least one negative and one positive value.
- Formula can’t find a result.
Let’s take the first case first.
In this example, we have listed down our cash flows within the range B2:B13. Now we will try to calculate the IRR using the formula below:
As we can see in the image above, excel returns a #NUM! error. The reason is pretty simple – the IRR function requires at least one negative value in the range as the initial cost of business.
So, in order to fix such an error, we can simply add our initial cost of business as a negative value to the cashflow range and the IRR function will display a valid result.
Another case, when the IRR function returns a #NUM error is when the function iterates and can’t find a result after several tries. We know that formulas like IRR and XIRR run several iterations to find an accurate answer.
However, Excel caps the number of iterations that these formulas go through so they’re not stuck in an infinite loop. When the formula maxes out the iterations without finding an answer, it returns a #NUM! error.
To overcome this, you have the option to increase the maximum number of iterations that Excel allows to get the result.
To increase the number of allowed iterations:
- Navigate to File>Options>Formulas to arrive at the window below
- Under the Calculation options group, check the Enable iterative calculation checkbox.
- In the Maximum Iterations textbox, enter the number of times you want Excel to perform iterations. Please note that – The higher the number of iterations, the more time and resources Excel might need to consume to display the result.
4. Fixing #NUM! error when you’ve entered an incorrect function argument
You can guess the fix before even looking through the example, can’t you? All you need to do is just enter the arguments correctly. Let’s look at how this will pan out practically.
Say you’ve got a few dates listed in two columns, and you’ve decided to find the differences between those dates. You remember reading our DATEDIF function tutorial, but you make a tiny mistake.
Understandable, right? If you read the DATEDIF tutorial carefully, you’ll see that Excel doesn’t show you the arguments you need to input as you type the formula, so this could be an easy mistake.
You use the start date as the end date and vice versa while applying the formula. So, you’ve incorrectly used the following formula.
The fix is simply to enter the arguments correctly into the formula, and that should eliminate the #NUM! error from your worksheet.
That’s all the ways you can deal with the #NUM! error whenever you find it on your worksheets. Child’s walk, right? While you champion eliminating #NUM! errors, we’ve got some more tutorials lined up for you. When you’re done, you know where to find us.
Subscribe and be a part of our 15,000+ member family!
Now subscribe to Excel Trick and get a free copy of our ebook «200+ Excel Shortcuts» (printable format) to catapult your productivity.
Источник
Have you ever wondered what Excel’s #NUM! error actually means? The #NUM! error can appear for several reasons: here are three of the most likely.
5 FREE EXCEL TEMPLATES
Plus Get 30% off any Purchase in the Simple Sheets Catalogue!
Reason 1: You are Performing an Impossible Calculation in Excel
If you perform an impossible calculation in Excel you will get the #NUM! error. An example of an impossible calculation is calculating the square root of a negative number using the SQRT function.
The #NUM! error will also appear if you try to find the logarithm of a negative number.
Reason 2: A Number is Too Big or Too Small
5 FREE EXCEL TEMPLATES
Plus Get 30% off any Purchase in the Simple Sheets Catalogue!
The smallest number you can use in Excel is -1*10^308. That’s a -1 with 308 zeros after it! The largest number is 1*10^308. That’s a 1 with 308 zeros after it! If you enter a number too small or too large you will get the #NUM! error.
For example, the formula =1000^500 (1000 multiplied by itself 500 times) would calculate a number too large for Excel, resulting in the #NUM! error.
Reason 3: You Are Using an Iterative Formula That Fails to Find a Result
An iterative formula is one that performs the same calculation again and again. An example of this is the IRR function which calculates the internal rate of return for a series of cash flows. IRR cycles through the calculation until the result is accurate within 0.00001 percent. If IRR can’t find a result that works after 20 tries, the #NUM! error value is returned.
#NUM error in Excel occurs when values in formulas are invalid.
It is mostly shown in cases where there is a problem with numbers i.e. the data type entered is not supported in the argument of the formula.
Once you adjust the number input, the calculation can be performed and the error disappears!
In the article, you will be shown the different reasons for #NUM error in Excel and how to fix it:
- What does #NUM mean in Excel?
- How to fix #NUM error in Excel?
- Conclusion
What does #NUM mean in Excel?
It basically means that the calculation cannot be performed due to limitations or errors.
This can be due to the fact that the number is too big or small. It also includes impossible calculations like calculating the square root of a negative number, or if the input for a function is invalid, or if an iterating formula like IRR cannot find the result.
Follow this detailed tutorial on #NUM Excel and download this Excel workbook to practice along and understand better:
How to fix #NUM error in Excel?
Let’s look into more detail and understand the causes and solutions to the #NUM! Excel.
Example 1 – Number size
Excel has a limitation to the size of the number that it can display. If you enter a number is too large or too small,you will get Excel #NUM Error.
As you can see, in cell C7 we are trying to multiply 5 by itself 500 times. The result will be a really large number that Excel is unable to display. Hence. it returns NUM Excel.
In cell C10, we are trying to divide 1 by 10^750. Since this will be a very small number Excel cannot perform calculations and hence returns #NUM error.
Excel is not able to show these values because of its inherent limitations. As shown, other smaller values are calculated and shown in C8 and C9.
Example 2 – Impossible calculations
Excel returns the #NUM! Error when it is faced with a calculation that is impossible to do.
As you can see, the square root or log of the positive numbers has results but the square root or log of the negative numbers is impossible to calculate.
In this example, we are trying to find the square root of -3.
Since we are trying to calculate the square root of a negative number, we will get #NUM error in Excel. In this particular case, you can rectify this issue by taking the absolute value of the number.
ABS function returns the absolute value of a number. It converts negative numbers to positive numbers and keeps the positive numbers unaffected.
Including the ABS function into the formula uses the absolute value of the number in column A, so now Excel can calculate the number and return a valid answer.
Example 3 – IRR function not working
Excel might show the #NUM! error when using IRR function because of either one of the two reasons:
- Cash flow does not contain at least one negative and one positive value.
- Formula can’t find a result.
In this example, Excel results a #NUM error instead of proving a value.
This is because the cash flows provided in the range (B7:B15) are positive and IRR requires at least one negative value as the initial cost of business.
Initial payments are provided as negative value indicating outflow of cash and income payments are represented by positive values. Once you have incorporated this, the function will provide the correct result!
IRR function can also display #NUM! error when the function iterates and can’t find a result after several tries.
To overcome this, you can increase the maximum number of iterations that Excel performs to get a result.
To increase the number of iterations:
STEP 1: Go to File > Options > Formulas to arrive at the window below
STEP 2: Under the Calculation options group, check the Enable iterative calculation box.
STEP 3: In the Maximum Iterations box, type the number of times you want Excel to recalculate.
The higher the number of iterations, the more time Excel needs to calculate a worksheet. Increasing this can help give a result to your calculation.
STEP 4: In the Maximum Change box, enter the amount of deviation that you are willing to accept between the calculation results.
The smaller the number, the more accurate the result. Increasing this can help give an approximate answer to your calculations.
Conclusion
After this exercise, we hope that you now understand why you were experiencing the #NUM error in Excel and that you can now easily rectify and overcome this error and continue with smooth functioning in Excel!
Make sure to download our FREE PDF on the 333 Excel keyboard Shortcuts here:
The #NUM! error is a frequent visitor on your worksheet. This can make you want to pull your hair out if you’ve used the output cell as a reference in another formula.
Looking for a fix? ExcelTrick has it for you.
What is a #NUM! Error in Excel?
#NUM! error occurs when you’ve entered a formula in your worksheet, but it can’t perform the calculation. For instance, say you’re trying to find square roots for a list of numbers. But there’s a negative value in the list. The formula will return a #NUM error for this value since it’s impossible to find the square root of a negative number.
But that’s not the only reason that can invite a #NUM! error into your worksheet. There are four possibilities that could be the reason for your perils. Fixing the error typically requires adjusting the values (no, it’s not mechanical, but an arithmetic error), and you’ll be set in no time.
Why Does it Appear?
So, why do #NUM! errors occur? Yes, as mentioned, there are four reasons. Let’s talk about them in a little more detail.
We already talked about the first reason in the previous section. If you’re trying to perform an impossible calculation, for instance, finding the square root of a negative number, you’ll get a #NUM! error.
The second reason could be that the output is too large or too small. The smallest and largest numbers that Excel can handle are -1*10^308 and 1*10^308, respectively. Excel displays any output outside this range as a #NUM! error.
The third reason could be that you’ve used an iterative formula that’s not finding a result. For instance, if you’re doing some capital budgeting and you’ve used the IRR formula in the process, and you see a #NUM! error, check the IRR formula. The IRR formula tries to calculate an answer that’s accurate down to 0.00001%. It tries to run about 20 iterations to find the answer. If it doesn’t, it returns the #NUM! error.
The fourth reason could be that you’ve entered an argument incorrectly in your function. For instance, think about the DATEDIF function. Things are all smooth sailing with this delightfully simple function, unless you mistakenly enter a start date that falls after the end date.
Sounds good? Perfect, let’s now try to look at how each of these reasons could play out on your worksheet and how to fix them with examples.
Examples
Following are some examples of when you’d see a #NUM! error.
1. Fixing #NUM! error when the calculation is impossible
When you’ve inadvertently asked Excel to perform an impossible calculation, you’ll see a #NUM! error. But the fix is, well, to make the calculation possible.
Let’s use the square root problem we discussed earlier. Say you’ve got some numbers in a list that you want a square root of, and you’ve applied the following formula to the numbers.
=SQRT(A2)
A negative number has sneaked into your list and caused a #NUM! error on your other spotless spreadsheet.
Once you’ve calmed yourself down from the panic of seeing the #NUM! error, think rationally. Since it’s impossible to find the square root of a negative number, you need to make it positive. The way to make it positive? The ABS function.
Here’s the formula you should use to fix the #NUM! error.
=SQRT(ABS(A2))
The ABS function converts the negative value into a positive one. When you enter a positive value into the SQRT function, everything should work fine. Easy-peasy, eh?
2. Fixing #NUM! error when the number is too large or small
The thing is… you can’t really fix this. If your output is too large or small for Excel, you’ll need to change your input to bring the output value within the acceptable range. For instance, say you’ve performed the following arithmetic operation in your Excel sheet:
=100^500
Now, there’s no chance that Excel will be able to display this value, and will therefore return a #NUM! error. There’s no way to display the result, so you’ll need to change the output.
3. Fixing #NUM! error resulting from an iteration formula
Functions like IRR can sometimes also lead to a #NUM error. Such errors are mainly because of two reasons:
- The specified Cash flow does not contain at least one negative and one positive value.
- Formula can’t find a result.
Let’s take the first case first.
In this example, we have listed down our cash flows within the range B2:B13. Now we will try to calculate the IRR using the formula below:
=IRR(B2:B13)
As we can see in the image above, excel returns a #NUM! error. The reason is pretty simple – the IRR function requires at least one negative value in the range as the initial cost of business.
So, in order to fix such an error, we can simply add our initial cost of business as a negative value to the cashflow range and the IRR function will display a valid result.
Another case, when the IRR function returns a #NUM error is when the function iterates and can’t find a result after several tries. We know that formulas like IRR and XIRR run several iterations to find an accurate answer.
However, Excel caps the number of iterations that these formulas go through so they’re not stuck in an infinite loop. When the formula maxes out the iterations without finding an answer, it returns a #NUM! error.
To overcome this, you have the option to increase the maximum number of iterations that Excel allows to get the result.
To increase the number of allowed iterations:
- Navigate to File > Options > Formulas to arrive at the window below
- Under the Calculation options group, check the Enable iterative calculation checkbox.
- In the Maximum Iterations textbox, enter the number of times you want Excel to perform iterations. Please note that – The higher the number of iterations, the more time and resources Excel might need to consume to display the result.
4. Fixing #NUM! error when you’ve entered an incorrect function argument
You can guess the fix before even looking through the example, can’t you? All you need to do is just enter the arguments correctly. Let’s look at how this will pan out practically.
Say you’ve got a few dates listed in two columns, and you’ve decided to find the differences between those dates. You remember reading our DATEDIF function tutorial, but you make a tiny mistake.
Understandable, right? If you read the DATEDIF tutorial carefully, you’ll see that Excel doesn’t show you the arguments you need to input as you type the formula, so this could be an easy mistake.
You use the start date as the end date and vice versa while applying the formula. So, you’ve incorrectly used the following formula.
=DATEDIF(B2,A2,"d")
The fix is simply to enter the arguments correctly into the formula, and that should eliminate the #NUM! error from your worksheet.
=DATEDIF(A2,B2,"d")
That’s all the ways you can deal with the #NUM! error whenever you find it on your worksheets. Child’s walk, right? While you champion eliminating #NUM! errors, we’ve got some more tutorials lined up for you. When you’re done, you know where to find us.
Transcript
What is a number format?
Number formats are used to control the display of cell values that contain numeric data. This numeric data can include things like dates, times, costs, percentages, and anything else expressed as a number. The most important thing to understand about number formats is that they only affect how a number looks—they have no effect on the actual value stored by Excel.
Let’s take a look.
The most common number formats are available on the home tab of the ribbon, in the Number format area. Here you’ll find formats for currency, numbers, date, time, and more.
To apply a number format, just select one or more cells and choose a format. Number formats only affect numbers; they have no effect on text.
Let’s format the rest of the values in our table.
After we have applied the formats, notice that Excel will display the name of the format when a cell is selected.
When you have multiple cells selected, you’ll see the format of the active cell displayed. Be aware that the active cell in a selection can vary, depending on how you select cells.
Most number formats have one or more options. To set number format options, and to see all number formats, visit the Format Cells dialog box. You can access this dialog by clicking the small arrow in the Number group on the ribbon or using the keyboard shortcut Ctrl-1. On the Number tab, you’ll find all the options available for each number format.
Let’s use the Format Cells dialog box to adjust the Fraction format. To get our fraction to display correctly, let’s format it to use hundredths.
Finally, remember that number formats only affect the display of a cell value, not the value itself. If we check the cells in our table, watching the formula bar, we see that the values are unchanged.
The value for Percentage looks different, but if we switch the format back to General, we see that the value being stored is, indeed, .05.
What does NUM mean in Excel?
Summary. The #NUM! error occurs in Excel formulas when a calculation can’t be performed. For example, if you try to calculate the square root of a negative number, you’ll see the #NUM! error.
How do I fix NUM in Excel?
How to correct a #NUM! error
- Select File > Options.
- On the Formulas tab, under Calculation options, check the Enable iterative calculation box.
- In the Maximum Iterations box, type the number of times you want Excel to recalculate.
How do I replace NUM in Excel with 0?
Step 1: Select the range that you will work with. Step 2: Press the F5 key to open the Go To dialog box. Step 3: Click the Special button, and it opens the Go to Special dialog box. Step 6: Now just enter 0 or any other value that you need to replace the errors, and press Ctrl + Enter keys.
How do you fix values in Excel?
In the Formula Bar, put the cursor in the cell which you want to make it constant, then press the F4 key. In this case, I don’t want the cell reference A1 to be adjusted with the formula moving, so I put the cursor on A1 in the formula, and then press F4.
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”.
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.
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.
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:
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:
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.
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:
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.
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”.
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)”:
And, in this case, the LEFT function returns 8, which is the first character of the address 857 King Street.
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.
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:
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”.
In this case, the formula for cell D3 is “=VALUE(C3)”.
And the result is the number 8:
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.
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.?”.
The formula for cell E3 is “=ISNUMBER(D3)”.
And the function returns TRUE, indicating that the value in cell D3 (and therefore the first character in the address) is a number.
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.
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”.
The IF formula for cell F3 is “=IF(E3=TRUE,B3,””)”.
And, as expected, this returns the first part of the desired address.
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.
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”.
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).
And, as planned, Excel returns the second part of the relevant address.
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.
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:
Deleting these references without any previous preparations leads to invalid cell reference errors appearing in column G. For example, in the case above:
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.
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:
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.
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.
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”.
Excel deletes all chosen rows. Now the table only has 1,000 rows, each corresponding to one of the 1,000 addresses.
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.
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.
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.
The formula for cell H3 is “=RIGHT(F3,1)”.
And the formula for cell I3 is “=RIGHT(G3,1)”.
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.
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.
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”.
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)”
And LEN returns the number of characters in the first part of the address.
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.
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.
After copying and pasting this formula in all the appropriate cells, the table looks roughly as follows:
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”.
You already know the syntax of the LEFT function. For example, the formula for cell L3 is “=LEFT(F3,K3)”.
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.
You can then copy and paste it for all the rows in the table.
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.
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:
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.
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:
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”.
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”.
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:
- 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:
- 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:
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”.
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)”.
Similarly, the formula in cell O3 is “=SEARCH(“,”,M3)”.
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).
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.
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”.
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)”.
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.
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.
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.
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”.
And then I type in the relevant formulas. For example, the formula for cell R3 is “=N3-1”.
And the formula for cell S3 is “=K3-N3”.
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.
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”.
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”.
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.
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.
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?
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:
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.
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)”.
Notice that the value returned by the LEFT function for the first address (999 River Street) is as expected (999).
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)”.
Just as in the previous case, the text returned by the RIGHT function for the first address is the correct one (River Street).
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)”.
Once again, the formula returns the appropriate data (Easton).
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)”.
And Excel returns the correct values.
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)”.
And you get the correct zip code as a result.
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.
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)”.
And Excel returns the expected address.
Copy and paste this formula in all the rows of column Z and you are completely done.
Really!
The table is ready.
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.
Having represented this site as a technology blog with a focus on programming and software development, I find myself starting off with a tutorial on Excel basics instead. Somehow, I thought it was going to be more glamorous than this . . . This is driven by my need to prepare a training for my staff at work, and in keeping with the DRY principle (Don’t Repeat Yourself) I am killing two birds with one stone. Anyone hoping to read programming stuff is just going to have to wait . . .
This is part two of a multi-part series targeting entry-level users of Microsoft Excel. In the previous post, we discussed the basic structure of a spreadsheet, and covered the vary basics of using expressions (or formulas). There is a LOT more to that, but before we go any further, it is important to understand how Excel understands data.
I am about to be a little long-winded. Hopefully you will slog through anyway, unless you already have a solid grasp on this stuff. Let’s take a (really) broad look at some data basics, before we explore the data type definitions specific to Excel. Because this is a long post, here are some navigation aids:
The Broad View – Information Basics
- What’s in a number? (numeric information)
- Truth Be Told (logical information)
- String Theory (Text information)
Details of Excel Data Types
- The Logical Data Type
- The Number Data Type
- The Text Data Type
- The Error Data Type
What’s in a number?
We humans don’t tend to think too hard about the type of data we are working with. We have evolved to be context-aware, and as we learn, we understand how to use MOST information within a particular context. For example, when we talk about our Social Security number, or our credit card number, we generally recognize either of those things as an identifier composed of numerical characters. We do not expect to be performing addition, multiplication, or other mathematical operations on these, even though semantically we still call them “numbers.” Further, both SSN’s and Credit Card account numbers might contain one or more leading zeros, or zeros at the rightmost end of the numerical sequence:
Example SSN: 001-11-1111
Never mind the dashes which make this SSN format behave emphatically NOT like a true number.
While most credit card companies assign a string of numerals as an account identifier (account number), other business entities might use a mixture of numerals and alphabetical characters to create account identifiers, which we still tend to refer to as “account numbers.” Again, while we think of the various account identifiers which (for some) rule our lives as “numbers”, we also tend to utilize them in a context more like a string of characters.
Contrast this with Social Security payments and/or credit card charges. These numbers represent numerical values which we contextually understand will be added to or subtracted from the current balance of our account. In a similar manner, the credit company will most likely perform a calculation (which, apropos of nothing whatsoever, would be represented by a formula) to determine how much interest to charge to our account. This amount would be calculated based upon our current balance (and a number of other factors), and then added to that balance for the current billing period. We intrinsically understand this, even though the actual math part may not be a part of our conscious thought stream.
In these cases, our human contextual ability allows us to (most of the time) use the right “numbers” in the correct and meaningful manner. Mentally, we all might play a quick mental arithmetic on our credit card account balance, subtracting the approximate amounts of our recent charges, before we decide to purchase that new 52″ HD television. When we whip out the plastic to punch the card number into the space on the Amazon website, we type in the set of numbers, recognizing that there is no numerical operation to be performed, other than making sure we type correctly.
[Back to Top]
Truth be Told . . .
On the other hand, we humans are nowhere near as good at evaluating a set of conditions and arriving at a concise logical value. We have to practice at this, and even then, our ability to inject that very same context can create flaws in our evaluation. We confuse our singular perceptions with absolutes. True logic is not relative. For example, on a very cold day here in Portland (say, 37 degrees F – yes, that would be “cold” here in the Pacific Northwest) one man might observe to another that it is “freezing out here” when in fact the temperature is well above the point at which liquid water changes state into its solid form. However, his companion is very likely to agree with him, or failing that, state that “yup, it’s cold out.”
Neither of these statements can be evaluated from a logical standpoint outside that of the observer, because they are relative statements. If an Inuit fresh from the North Slope of Alaska were to join the group, he would likely find the observations of the other two men absurd. To the Inuit, the actual outdoor temperature of, say, 37 degrees might feel nearly tropical. In fact, since “freezing” is technically defined as the point at which water turns to ice (32 degrees Fahrenheit, or 0 degrees Celsius), the only valid logical statement which could be made in this situation is that it is NOT, in fact, freezing outside.
As humans, we are accustomed to applying our personal, regional, and societal metrics in evaluating information. Our computers, however, and by extension the software which runs on them, are machines which deal in absolutes. To the machine, a statement which is not 100% true is FALSE. Numbers may be manipulated in meaningful mathematical ways, while arrangements of text cannot (or at least, not in the same manner as true numbers).
Despite some illusions built into our modern software (including Microsoft Excel) to the contrary, the computer does not understand context. The computer is very, very literal and will perform whatever action or calculation you request of it (unless, of course, the programmer built in a mechanism to prevent the operation from being carried out if certain conditions aren’t met) with no comprehension of the sensibility of the result.
At the very, very most basic level, TRUE and FALSE (in a technical sense, ON and OFF) are the only two things the computer hardware understands. After one delves down through several layers of software abstraction, one eventually runs into hardware which is binary in nature. Binary code is composed of ones and zeros, representing ON (one) and OFF (zero). We are not going to go into how all THAT works here. But its important to understand the literal nature of the machine, that the machine lacks ANY “context” beyond that supplied by the programmer, and that all of the information we work with in our user-friendly, usability-tested software interface has been heavily abstracted for our benefit.
There is an entire branch of mathematics devoted to logical analysis called Boolean Algebra. While we won’t be going into that in this article, an understanding of basic logical operations can lend itself well to some advanced spreadsheet features that will make you the envy of your friends, and the champion around the office. More in a bit.
[Back to Top]
String Theory
I am NOT about to embark on a discussion of theoretical physics.
I am going to talk about text. Like, words. This overly long post is constructed of words, in the English language, which I have typed in to the computer using my keyboard. I am currently creating this post using Windows Live Writer, a nifty blogging program which has abstracted away the need for me to understand all that goes into marking up my blog post with suitable HTML, creating an ftp connection, and uploading the content into the proper directories on the server so that it displays properly for you, the reader. I just type, and when I am done, I use mu mouse cursor to push an on-screen representation of a “button” that says “publish”. In the same manner, our software tends to abstract from us the need to understand what is really going un “under the hood” when we ask our machines to work with text. It appears to us, as end users, that the machine recognizes the strings of characters we type and manipulate, and works with text just as easily as it works with numbers.
Which is emphatically not true.
We’re not going to go into the how and why of it right now, but let’s just say that creating effective ways for our machines to handle input, display, formatting, and printing of text (not to mention standardization across platforms!) has been one of the major challenges of the PC era. Just to give you an idea, here are a couple of entertaining and informative articles by Joel Spolsky on the topic of character strings. It is not required reading for our purposes here, but you may find it informative:
- Back to Basics (aka The Schlemiel the Painter Article)
- The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Suffice it to say, it is important to be aware that text information lives in its own realm, even within the confines of our simple spreadsheet. Even more important, it is REALLY important for you, the reader, to be able to properly distinguish whether your spreadsheet should be treating the information in a cell as text, or something else. We’ll see why in the next post.
A final comment before we get into the nitty gritty. At a basic level, the text we take for granted on screen is regarded by our machine as a string of characters. These characters are actually ASCII or Unicode representations of what we actually see displayed. Because our words, sentences, and paragraphs (including whitespace and non-printing items such as carriage returns, tabs and other markup) are all composed of such character strings, we will often refer to text data as strings. In other words, in your travels, whether in Excel or some other application, mention is made of “String Parameter”, “String Data Type”, etc. you can generally substitute “text” for “string” and be just fine.
Ok. Now that we have the preliminaries out of the way, let’s look at how Microsoft Excel regards our data.
[Back to Top]
Data Types
Microsoft Excel recognizes four kinds of information: Logical values (TRUE or FALSE, also called Boolean values), Numerical values, Text values, and Error types. The four kinds of information are known, in technical parlance, as Data Types. What is important for you, the user, is to begin to think of your own information in this manner, and consider how the machine is going to use it.
Note that Excel will do the very best it can to figure out which of these types it THINKS you intend, once you complete typing into a cell and hit the enter key. For example, if you type a series of numerals, it assumes you intend a number type. If that series of numerals happens to begin with one or more zeros, Excel STILL thinks you intend to type a number, and eliminates those leading zeros. Likewise, if you type something the looks like a date, and contains valid numbers which can represent a valid date, Excel assumes you mean a number type again, formatted as a date.
You will learn more about this date stuff later in the post. However, be aware that Excel tries to help you in this manner. Most of the time, it works out. Sometimes, it doesn’t, and then you have to help Excel by telling it what you REALLY mean, explicitly.
The Logical Data Type
Logical values are either TRUE or FALSE.
In most cases, logical values will be present as the result of the evaluation of an expression or function. Essentially, a logical value represents the resolution of an expression indicating whether certain conditions have been met. For example:
The statement “1 is less than 2” is recognizable as a true statement. Another way to put that is:
1 < 2 = TRUE
When evaluating logical expressions, Excel recognizes the text TRUE as a logical (or boolean) value. Excel also treats the value 0 as false, and any other numerical value as true. For example, we can make a logical comparison about the values in two different cells by typing an expression:
If we add change one of the values, the expression will no longer return true:
Logical expressions are one of the more powerful tools Excel has to offer, and yet they are also some of the least utilized. We will devote an entire post to examining logical expressions in the near future.
[Back to Top]
The Number Data Type
Numerical values are, of course, numbers. This is more complex than it first appears, however. First of all, Excel stores all numbers as Double-Precision Floating Point values. I know. It’s a mouthful. For our purposes here, you can think of that as a decimal number, with room for a lot of decimal places if needed. Excel can store numbers as large as 1.79768 X 10308 and as small as 2.2250 X 10-308. These represent extremely large, and extremely small numbers, respectively.
The thing to remember here is that to Excel, all of the following are numbers: 15,000; 100; $50; $50.00; 75%; 0.5; 5.35E+04; and 12/25/2012.
What, you say? What was that last? Yes. To Excel, dates are also stored as plain old numbers. We’ll discuss THAT in a minute. For the moment, take a look at what you might type in or see displayed in a cell, vs. what excel is actually storing:
Visible in Cell | 15,000 | 100 | $50,000 | $50.00 | 75% | .5 | 5.35E+04 | 12/25/2012 |
Number Stored | 15000 | 100 | 50000 | 50 | 0.75 | 0.5 | 53500 | 41268 |
While you are likely familiar with most of the numbers you see in the table above, some of you may not be familiar with the second from the right, known as Scientific E notation. Don’t worry about that right now. Scientific E notation is a a sort of shorthand for expressing very large (or very small) numbers The example above is trivial for the purpose of illustration. Trust me that the expression in the top cell is numerically equivalent to the number displayed in the cell below.
The important thing to remember is that numbers in Excel can be no more than 15 significant digits in length. This excludes zeros on either side of the number:
99999999999999900000 is 20 numerals, but only contains 15 significant digits; the fifteen “9’s” to the left of the five zeros. Likewise, .00000999999999999999 is also twenty decimal places, but contains only fifteen significant digits).
Numbers which are entered that contain more than 15 significant digits will be truncated. That is, significant digits will be lopped off the right-hand side and replaced with zeros. Note in the examples below, we can type in 19 significant digits (fourteen 9’s followed by 87654). Once we hit “Enter”, the significant digits in excess of 15 are truncated, leaving 0’s):
Dates and Times
Ok. Now on to that date thing. Dates and times are also stored as number types by Excel. Dates are stored as the number of days since the date 1/1/1900. In other words, January 1, 1900 is considered by Excel to be 1. Therefore, 1/2/1900 would be stored as 2, 1/3/1900 as 3, and so on. Note that Excel does not recognize dates BEFORE 1/1/1900. We’ll see why this matters in the next post about functions and expressions.
Excel treats Times as fractions of days. Since a day is 24 hours in length, then 1/4th of a day (0.25) would be 6 hours. Since each day begins at 0 hours and 24 hours later, Excel would store the date and time for 6:00 AM on 1/1/1900 as 1.25. As I type this sentence, it is 10:39 PM on August 9th, 2011. Therefore, Excel would store the current date and time as 40764.94384. That is, forty thousand three-hundred eighty-four and (roughly) 94/100ths days since 1/1/1900.
Values vs. Formats
The key thing about numbers in Excel is that you need to separate in your mind the number VALUE from the way it is DISPLAYED. The manner in which Excel displays a given numerical value within a cell is known as formatting. We will discuss different aspects of number formatting later, but for the moment, keep in mind that underneath whatever window dressing Excel provides in terms of formatting, the following are all representations of the same value (1.05):
1.05 = 1.050000 = $1.05 = 105% = 1/1/1900
Value in Cell | Format | Displayed in Cell |
1.05 | General | 1.05 |
1.05 | Number (6 digit decimal precision) | 1.050000 |
1.05 | Currency | $1.05 |
1.05 | Percent | 105% |
1.05 | Date | 1/1/1900 |
Likewise, these ALSO represent the same numerical value (.75):
.75 = $0.75 = 75% = 3/4 = 6:00:00 PM
Value in Cell | Format | Displayed in Cell |
0.75 | General | 1.05 |
0.75 | Currency (2 digit decimal precision) | $0.75 |
0.75 | Percent (1 digit decimal precision) | 75.0% |
0.75 | Fraction | 3/4 |
0.75 | Time (hh:mm PM) | 6:00:00 PM |
We’ll cover the ins and outs of the various formatting choices in the next post. But be aware, that formatting can be tricky. Notice how, in the first example above, if we choose to format the value 1.05 as a Date, we get the displayed value of 1/1/1900. In a way, this is to be expected, since we learned that in Excel, the number 1 can be considered to represent 1/1/1900. But what about that .05 (five one-hundredths)? Well, this would actually represent 1/20th of 1 day (5/100ths reduces to 1/20th). But since we specified a date format which did not include the time as part of the format to display, we get only the date.
The value of a number is stored in the cell. Formatting determines how the number is displayed, and what level of precision is displayed. When using the value of the cell in calculations, the true value is used, not the displayed value!
We will see how this might matter in a later post. For now, we will move on the the Text data type.
[Back to Top]
The Text Data Type
As we discussed previously, Microsoft Excel regards test as strings of characters. The letters of the alphabet, numerical characters, symbols such as % and $, as well as spaces and tabs are all valid text. In cases where Excel cannot distinguish a value as either a number type, a logical type, or an error type, the value will be treated as text.
Excel will recognize a text string of up to 32,768 characters. However, only 1024 can be displayed in a cell.
Excel tries to be helpful, in that, as you enter information into a cell, the application attempts to determine what type of data you are entering and treat it accordingly. Most of the time this is fine, and helpful. However, sometimes it can trip us up. For example, we will return to the issue of leading zeros and account numbers. Lets say an account number begins with four zeros:00001234567891011. If we were to simply enter this string of numbers into a cell, excel will decide we are entering a number value, and will drop those leading zeros.
We can tell Excel to treat the data in a cell as text by pre-pending a single-quote character before the text we wish to enter, or by applying the text format to the cell through the cell formatting menu (which we will discuss in the next post).
Excel offers a host of text manipulation functions which we will examine in an upcoming post.
The Error Data Type
There are instances in which errors will occur when Excel evaluates the contents of a cell. For example, division by zero is mathematically undefined, and the machine cannot, by itself, resolve this error. It turns out the Excel has an Error type specifically for this instance, the #DIV/0! result.
The error type generally rears its ugly head due to problems with functions or formulas. The different error values Excel provides are listed in the following table, along with the meaning of the error:
Error Value | Means | Common Causes |
#DIV/0 | Division by zero | You attempted to divide by a value of zero. A blank cell is treated as zero in mathematical operations. |
#N/A | No value Available | Manually entered (and sometimes when data is imported) to indicate information not available |
#NAME? | Excel does not recognize the name of a list or range of cells | The #NAME? error will result if you neglect to enclose text in quotes within a formula, or if you refer incorrectly to the name (address) of a cell or range of cells. |
#NULL! | Reference to a non-existent intersection between two cell ranges | If you neglect to separate to cell ranges with a comma in certain function arguments, the #NULL! Error will result. Also if you refer to an intersection between two cell ranges which do not intersect. |
#NUM! | There is a problem with a number in a formula or result | Passing an invalid argument to a function or formula, or a formula returns a number which is too large or too small to be represented in the cell. |
#REF! | Invalid Cell Reference | You have deleted or pasted over a cell or cells referred to in a formula. |
#VALUE! | Invalid argument or operator in a function or formula | Usually results from performing a mathematical operation with cells that contain text. |
The short version of all this is that when you see that ugly hash symbol, you know you have a problem, usually in a formula. This reference will help you know where to begin looking for the problem.
OK. We’ve covered a lot of ground. In the next post we will take a closer look at formulas and some of the built-in functions Excel provides.
[Back to Top]
Summary
Understanding how Microsoft Excel interprets and handles different types of information is critical in constructing effective spreadsheets. Failure to properly anticipate how Excel will work with your data can potentially lead to calculation errors which are difficult to detect. In order to make the most effective use of expressions and formulas, and functions within Excel, an awareness of the various data types within the program will save time, frustration, and headaches.
- It is important to consider that the computer does not have a contextual understanding of our information, beyond what the programmers built in.
- Excel will attempt to determine the proper data type based on what you type into a cell. Sometimes you have to correct for this.
- Excel recognized four types of data;
- The Logical Type:
- Indicates a value of TRUE or FALSE
- A value of zero = FALSE; Any value other than zero = TRUE
- The Number Type
- All numbers are represented by a Double-Precision Floating Point value (big decimal numbers).
- Numbers may contain up to 15 significant digits (exclude zeros on either side of the number).
- Numbers may be as large as 1.79768 X 10308 or as small as 2.2250 X 10-308.
- The number value is stored in the cell. Formatting determines how the number is displayed, and what level of precision is displayed. The precision of the value stored in the cell is not affected by the display format.
- Dates and times are stored as number values.
- The date 1/1/1900 is represented by the number 1, and successive dates are numbered as days since that date.
- Times are stored as fractional parts of days. 1/4 = 1/4th of one day = 24/4 = 6 hours from the beginning of the day, or 6:00 AM.
- The Text Type
- Text is regarded by the computed as strings of characters
- All characters can be stored as Text (A-Z, a-z, 0-9, !@#$ etc.)
- Data which Excel cannot resolve to either a Number Type or a Logical Type is stored as Text.
- Excel will recognize a text string of up to 32,768 characters. However, only 1024 can be displayed in a cell.
- Inserting a single quote character as the first character in a cell will tell Excel to store the data in the cell as Text, even if it composed entirely of numerals.
- The Error Type
- The error type is returned when Excel encounters an error in evaluating the contents of a cell.
- The Error Type generally occurs because of a problem in a formula.
- The Logical Type:
Next: A Closer Look at Expressions and Formulas
Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
This article describes the formula syntax and usage of the N function in Microsoft Excel.
Description
Returns a value converted to a number.
Syntax
N(value)
The N function syntax has the following arguments:
-
Value Required. The value you want converted. N converts values listed in the following table.
If value is or refers to |
N returns |
A number |
That number |
A date, in one of the built-in date formats available in Microsoft Excel |
The serial number of that date |
TRUE |
1 |
FALSE |
0 |
An error value, such as #DIV/0! |
The error value |
Anything else |
0 |
Remarks
-
It is not generally necessary to use the N function in a formula, because Excel automatically converts values as necessary. This function is provided for compatibility with other spreadsheet programs.
-
Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900.
Example
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Data |
||
7 |
||
Even |
||
TRUE |
||
4/17/2011 |
||
Formula |
Description |
Result |
=N(A2) |
Because A2 contains a number, the number is returned. |
7 |
=N(A3) |
Because A3 contains text, 0 is returned. |
0 |
=N(A4) |
Because A4 is the logical value TRUE, 1 is returned. |
1 |
=N(A5) |
Because A5 is a date, the serial number of the date is returned (varies with the date system used). |
40650 |
=N(«7») |
Because «7» is text, 0 is returned. |
0 |