18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Part II<br />

Working with Formulas and Functions<br />

The following array formula is similar to the previous one, but it returns the actual cell address of the maximum<br />

value in the Data range. It uses the ADDRESS function, which takes two arguments: a row number<br />

and a column number.<br />

{=ADDRESS(MIN(IF(Data=MAX(Data),ROW(Data), “”)),COLUMN(Data))}<br />

The previous formulas work only with a single-column range. The following variation works with any sized<br />

range and returns the address of the smallest value in the range named Data:<br />

=ADDRESS(MIN(IF(Data=MAX(data),ROW(Data), “”)),<br />

MIN(IF(Data=MAX(data),COLUMN(Data), “”)))<br />

Finding the row of a value’s nth occurrence in a range<br />

The following array formula returns the row number within a single-column range named Data that contains<br />

the nth occurrence of the value in a cell named Value:<br />

{=SMALL(IF(Data=Value,ROW(Data), “”),n)}<br />

The IF function creates a new array that consists of the row number of values from the Data range that are<br />

equal to Value. Values from the Data range that aren’t equal to Value are replaced with an empty string. The<br />

SMALL function works on this new array and returns the nth smallest row number.<br />

The formula returns #NUM! if the Value is not found or if n exceeds the number of the values in the range.<br />

Returning the longest text in a range<br />

The following array formula displays the text string in a range (named Data) that has the most characters. If<br />

multiple cells contain the longest text string, the first cell is returned.<br />

{=INDEX(Data,MATCH(MAX(LEN(Data)),LEN(Data),FALSE),1)}<br />

This formula works with two arrays, both of which contain the length of each item in the Data range. The<br />

MAX function determines the largest value, which corresponds to the longest text item. The MATCH function<br />

calculates the offset of the cell that contains the maximum length. The INDEX function returns the contents<br />

of the cell containing the most characters. This function works only if the Data range consists of a single<br />

column.<br />

Determining whether a range contains valid values<br />

You may have a list of items that you need to check against another list. For example, you may import a list<br />

of part numbers into a range named MyList, and you want to ensure that all the part numbers are valid. You<br />

can do so by comparing the items in the imported list to the items in a master list of part numbers (named<br />

Master).<br />

The following array formula returns TRUE if every item in the range named MyList is found in the range<br />

named Master. Both ranges must consist of a single column, but they don’t need to contain the same number<br />

of rows.<br />

{=ISNA(MATCH(TRUE,ISNA(MATCH(MyList,Master,0)),0))}<br />

The array formula that follows returns the number of invalid items. In other words, it returns the number of<br />

items in MyList that do not appear in Master.<br />

{=SUM(1*ISNA(MATCH(MyList,Master,0)))}<br />

338

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!