11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

404<br />

Part IV: Array <strong>Formula</strong>s<br />

Returning the last value in a column<br />

Suppose that you have a worksheet that you update frequently by adding new data to columns.<br />

You may need a way to reference the last value in column A (the value most recently entered). If<br />

column A contains no empty cells, the solution is relatively simple and doesn’t require an array<br />

formula:<br />

=OFFSET(A1,COUNTA(A:A)–1,0)<br />

This formula uses the COUNTA function to count the number of nonempty cells in column A. This<br />

value (minus 1) is used as the second argument for the OFFSET function. For example, if the last<br />

value is in row 100, COUNTA returns 100. The OFFSET function returns the value in the cell 99<br />

rows down from cell A1 in the same column.<br />

If column A has one or more empty cells interspersed, which is frequently the case, the preceding<br />

formula won’t work because the COUNTA function doesn’t count the empty cells.<br />

The following array formula returns the contents of the last nonempty cell in column A:<br />

{=INDEX(A:A,MAX(ROW(A:A)*(A:A””)))}<br />

You can, of course, modify the formula to work with a column other than column A. To use a different<br />

column, change the column references from A to whatever column you need.<br />

You can’t use this formula, as written, in the same column in which it’s working.<br />

Attempting to do so generates a circular reference. You can, however, modify it. For<br />

example, to use the function in cell A1, change the references so that they begin with<br />

row 2 rather than the entire columns. For example, use A2:A1000 to return the last<br />

non-empty cell in the range A2:A1000.<br />

Returning the last value in a row<br />

The following array formula is similar to the previous formula, but it returns the last nonempty<br />

cell in a row (in this case, row 1):<br />

{=INDEX(1:1,MAX(COLUMN(1:1)*(1:1””)))}<br />

To use this formula for a different row, change the 1:1 reference to correspond to the row.<br />

Ranking data with an array formula<br />

Often, computing the rank orders for the values in a range of data is helpful. If you have a worksheet<br />

containing the annual sales figures for 20 salespeople, for example, you may want to know<br />

how each person ranks, from highest to lowest.

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

Saved successfully!

Ooh no, something went wrong!