Yesterday, in the 30XL30D challenge, we had a light day, with the N function, and learned that can return a number, based on a value.
FIND Function
For day 23 in the challenge, we’ll examine the FIND function. It’s similar to the SEARCH function, which we saw on Day 18, but the FIND function is case sensitive.
So, let’s take a look at the FIND information and examples, and if you have other tips or examples, please share them in the comments.
Yesterday, in the 30XL30D challenge, we got cell addresses with the ADDRESS function, and combined it with INDIRECT to get a cell’s value.
TYPE Function
For day 21 in the challenge, we’ll examine the TYPE function. It identifies the type of value in a cell, by returning a number.
So, let’s take a look at the TYPE information and examples, and if you have other tips or examples, please share them in the comments.
Function 21: TYPE
The TYPE function returns a number, that identifies a value’s type:
Here’s the list of results, and the data types:
How Could You Use TYPE?
The TYPE function can tell you what kind of value is in a cell, but the logical functions, like ISERROR, ISTEXT, etc., will also check for a specific data type.
However, if you just want to know what’s in a cell, the TYPE function can:
Identify cell value type by number
Test for Number type before multiplying
TYPE Syntax
The TYPE function has the following syntax:
TYPE(value)
value can be text, number, error, or any other value
TYPE Traps
Unfortunately, the TYPE function cannot identify cells that contain a formula. It only shows the type for a cell’s contents, or a formula’s result.
In a few versions of Excel, the Help files incorrectly reported that a formula would return 8 with the TYPE function. This MSKB article corrects that error.
The TYPE function returns number, based on a value’s type, so you can use it to see what’s in a cell. For example, if you type 123 in cell B3, the result of this formula is 1 — Number.
=TYPE(B3)
Identify cell value type by number with TYPE function
However, if there is an apostrophe in front of the number, the TYPE function result would be 2 — Text.
Example 2: Test for Number type before multiplying
You could use the TYPE function with CHOOSE, to multiply valid numbers, or show a message, if something else is entered.
If a number is entered in B3, the TYPE function returns 1, so the CHOOSE function returns the result of B3*C3.
If text is entered in B3, the TYPE function returns 2, so the CHOOSE function returns the message “No text”.
If anything else is entered in B3, the TYPE function returns a 4 or higher. The MIN function result will be 3, so the CHOOSE function returns the message “Enter Qty”.
Download the TYPE Function File
To see the formulas used in today’s examples, you can download the TYPE function sample workbook. The file is zipped, and is in Excel 2007 file format.
Watch the TYPE Video
To see a demonstration of the examples in the TYPE function sample workbook, you can watch this short Excel video tutorial.
Yesterday, in the 30XL30D challenge, we found items in an array with the MATCH function, and learned that it plays nicely with other functions, like VLOOKUP and INDEX.
ADDRESS Function
For day 20 in the challenge, we’ll examine the ADDRESS function.
Yesterday, in the 30XL30D challenge, we found text strings with the SEARCH function, and used IFERROR and ISNUMBER to deal with its error results.
MATCH Function
For day 19 in the challenge, we’ll examine the MATCH function. It searches for a value in an array, and returns its position, if the value is found.
To see a the MATCH function sample workbook, you can watch this short video. There are written steps below the video
Function 19: MATCH
The MATCH function returns the position of a value in an array, or #N/A if not found. The array can be sorted, or unsorted, and the MATCH function is not case sensitive.
How Could You Use MATCH?
The MATCH function returns the position of an item in an array, and that result can be used by other functions, such as INDEX or VLOOKUP. For example:
Find position of item in unsorted list
Use with CHOOSE to get student grades
Use with VLOOKUP for flexible column choice
Use with INDEX for to show winner’s name
MATCH Syntax
The MATCH function has the following syntax:
MATCH(lookup_value,lookup_array,[match_type])
lookup_value can be text, number or logical value
lookup_array is an array, or array reference (contiguous cells in a single row or column)
match_type can be -1, 0 or 1. If omitted, assumed to be 1
MATCH Traps
MATCH function returns the position of the item found, not the value. If you need the value, combine MATCH with another function, like INDEX.
Example 1: Find Item in Unsorted List
For an unsorted list, you can use 0 as the match_type argument, to find an exact match. If you’re searching for text, and using 0, you can include wildcard characters in the lookup value.
In this example, you can type a month name, or partial name with wildcards, to find that month’s position in the list.
=MATCH(D2,B3:B7,0)
Find Item in Unsorted List with MATCH function
Instead of an array reference, you can enter an array as the lookup_array argument.
In this variation, the lookup month name is entered in cell D5, and three month names are entered in the MATCH function’s second argument.
If a later month, such as Oct, is entered in D5, the result will be #N/A.
=IF(C2+0<14,”Time to upgrade”,”Latest version”)
Example 2: Change Student Grades to Letters
Just as you did with VLOOKUP, you can use MATCH to help convert a student’s score to a letter grade. In this example, it is combined with CHOOSE, to get the letter grade. The match_type is -1, because the scores are sorted in descending order.
When the match_type is -1, the result is the smallest value greater than or equal to lookup value. The lookup value is 54, and it’s not in the list of scores, so the position for 60 is returned.
Because 60 is in position 4, the 4th value in the CHOOSE options is the result — cell C6, with a value of D.
=CHOOSE(MATCH(B9,B3:B7,-1),C3,C4,C5,C6,C7)
Example 3: Create Flexible Column Choice in VLOOKUP
To make a VLOOKUP formula more flexible, you can use MATCH to find a column number, instead of hard-coding it into the formula.
In this example, users can select a region in cell H1, as the value for the VLOOKUP. Then, they can select a Month in cell H2, and the MATCH function returns the column for that month.
=VLOOKUP(H1,$B$2:$E$5,MATCH(H2,B1:E1,0),FALSE)
Example 4: FIND Closest Match with INDEX
The MATCH function also works well with the INDEX function, which we’ll see later in the challenge.
In this example, the MATCH function is used to find the guess that is closest to the correct number.
The ABS function returns the absolute difference between each guess and the correct number.
The MIN function finds the smallest difference.
The MATCH function finds the smallest difference in the list of differences. If there are multiple identical differences, the first one will be returned.
The INDEX function returns the name in that position in the list of names.
To see the formulas used in today’s examples, you can download the MATCH function sample workbook. The file is zipped, and is in Excel 2007 file format.
Watch the MATCH Video
To see a demonstration of the examples in the MATCH function sample workbook, you can watch this short Excel video tutorial.
Yesterday, in the 30XL30D challenge, we identified errors with the ERROR.TYPE function, and saw that it could help with Excel troubleshooting.
SEARCH Function
For day 18 in the challenge, we’ll examine the SEARCH function. It looks for a character, or characters, within a text string, and tells you where it was found. We’ll see how to handle any errors that it returns.
Yesterday, in the 30XL30D challenge, we found values with the LOOKUP function, and we’ll use that function again today, when working with error results.
ERROR.TYPE Function
For day 17 in the challenge, we’ll examine the ERROR.TYPE function. It can identify specific types of errors, and you can use that information to help with troubleshooting.
So, let’s take a look at the ERROR.TYPE information and examples, and if you have other tips or examples, please share them in the comments.
Watch the ERROR.TYPE Video
To see a demonstration of the examples in the ERROR.TYPE function sample workbook, you can watch this short Excel video tutorial.
Function 17: ERROR.TYPE
The ERROR.TYPE function identifies an error type by number, or returns #N/A if no error is found.
How Could You Use ERROR.TYPE?
With the ERROR.TYPE function, you can:
identify an error type
help users troubleshoot error results
ERROR.TYPE Syntax
The ERROR.TYPE function has the following syntax:
ERROR.TYPE(error_val)
error_val is the error that you want to identify
ERROR.TYPE codes:
1…..#NULL!
2…..#DIV/0!
3…..#VALUE!
4…..#REF!
5…..#NAME?
6…..#NUM!
7…..#N/A
#N/A..Other
ERROR.TYPE Traps
If the error_val is not an error, the result of the ERROR.TYPE function is an #N/A error. You can avoid this, by using ISERROR to test for an error, as shown in Example 2.
Example 1: Identify the Error Type
With the ERROR.TYPE function you can check a cell, to identify which error it contains.
If there isn’t an error in the cell, the result is #N/A, instead of an error type code number.
=ERROR.TYPE(B3)
Identify the Error Type with ERROR.TYPE Function
In this example, cell B3 contains #VALUE!, so the error type is 3.
Example 2: Help Users Troubleshoot Errors
By combining the ERROR.TYPE function with other functions, you can help users troubleshoot error results in a cell.
In this example, numbers should be entered in cells B3 and C3.
If text is entered, the result in D3 is a #VALUE! error.
If a zero is entered in cell C3, the result is a #DIV/0! error.
In cell D4, ISERROR checks for an error, and the ERROR.TYPE function returns a number for the error. The LOOKUP function finds the applicable troubleshooting message from a table of error type codes, and displays it.
On that page, go to the Download section, to get the ERROR.TYPE function sample workbook. The file is zipped, and is in xlsx file format, with no macros.
Yesterday, in the 30XL30D challenge, we had some fun with the REPT function, and created in-cell charts and a tally sheet. Now it’s Monday, and time to put those thinking caps back on!
LOOKUP Function
For day 16 in the challenge, we’ll examine the LOOKUP function. It’s a close friend of VLOOKUP and HLOOKUP, but works in a slightly different way.
So, let’s take a look at the LOOKUP information and examples, and if you have other tips or examples, please share them in the comments.
Function 16: LOOKUP
The LOOKUP function returns a value from a one-row or one-column range, or from an array, which can have multiple rows and columns.
How Could You Use LOOKUP?
The LOOKUP function can return a result, based on a lookup value, such as:
Find last number in a column
Find latest month with negative amount
Convert student percentages to letter grades
LOOKUP Syntax
The LOOKUP function has two syntax forms — Vector and Array. With Vector form, it looks for a value in a specified column or row, and with Array form, it looks in the first row or column of an array.
The Vector form has the following syntax:
LOOKUP(lookup_value,lookup_vector,result_vector)
lookup_value can be text, number, logical value, a name or a reference
lookup_vector is a range with only one row or one column
result_vector is a range with only one row or one column
lookup_vector and result_vector must be the same size
The Array form has the following syntax:
LOOKUP(lookup_value,array)
lookup_value can be text, number, logical value, a name or a reference
searches based on the array dimensions:
if there are more columns than rows, it searches in the first row
if equal number, or more rows, it searches first column
returns value from same position in last row/column
LOOKUP Traps
The LOOKUP function doesn’t have an option for Exact Match, which both VLOOKUP and HLOOKUP have. If the lookup value isn’t found, it matches the largest value that is less than the lookup value.
The lookup array or vector must be sorted in ascending order, or the result might be incorrect.
If the first value in the lookup array/vector is bigger than the lookup value, the result is an #N/A error.
Example 1: Find Last Number in Column
In the Array form, you can use the LOOKUP function to find the last number in a column.
The specifications in Excel’s Help list 9.99999999999999E+307 as the largest number allowed to be typed into a cell. In this formula, that number is entered as the lookup value. Assuming that large number won’t be found, the last number in column D is returned.
In this example, the numbers in column D do not have to be sorted, and there are text entries included in the column.
=LOOKUP(9.99999999999999E+307,D:D)
Find Last Number in Column with LOOKUP function
Example 2: Find Latest Month With Negative Amount
This example uses LOOKUP in its Vector form, with sales amounts in column D, and month names in column E. Things didn’t go well for a few months, and there are negative amounts in the sales column.
To find the last month with a negative amount, this LOOKUP formula tests each sales amount to see if it’s less than zero. Then, 1 is divided by that result, and returns either a 1 or a #DIV/0! error.
The lookup value is 2, which won’t be found, so the last 1 is used, to return the month name from column E.
=LOOKUP(2,1/(D2:D8<0),E2:E8)
Example 3: Convert student percentages to letter grades
Just as you did with the VLOOKUP formula, you can use LOOKUP, in its Vector form, to find the letter grade for a student’s percentage score. With LOOKUP, the percentage do not have to be in the first column of the lookup table — you can specify any column.
Here, the scores are in column D, sorted in ascending order, and letter grades are in column C, to the left of the lookup column.
Yesterday, in the 30XL30D challenge, we took things easy, with the T function.
REPT Function
For day 15 in the challenge, we’ll examine the REPT function, which repeats a text string, a specified number of times. It’s another Text function, and has a few interesting uses.
Welcome to another weekend in the 30XL30D challenge, and you’re probably exhausted from a long week of Excel work, and yesterday’s complicated example for the TRANPOSE function.
Excel T Function
For day 14 in the challenge, we’ll examine the Excel T function