Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

finding the final cell with a value in a specific column?

I need to take the final cell in a column on one worksheet & put it into a summary worksheet within the same file. I believe I'm supposed to be using the LOOKUP formula, but I can only get it to return the first cell in the range; I need the last cell. The worksheet will be updated almost daily, so I want the summary to reflect the most recent information.


Can anyone help me with this?

iWork-OTHER, Mac OS X (10.6.8), Numberds

Posted on Dec 2, 2011 10:46 AM

Reply
13 replies

Dec 2, 2011 11:45 AM in response to Trey Hill

Hi Trey,


More precise detail needed in your description:


Your subject line says "the final cell with a value," implying there may be empty cells above or below the target cell.

In the body of your message you say, "the final cell in a column."


These specifications could cover at least three different situations, each of which would require a different technique to locate the target cell and return it's stored value.


Can you give a more precise description of the possible cases?


Regards,

barry

Dec 2, 2011 12:06 PM in response to Barry

All cells in the column in question will be filled in up to a point and the column will be added to several times a week. So, I need the final cell w/ a value to be pulled forward into a summary worksheet. The address of that cell will change as more rows are added.


I've used =LOOKUP(Game Stats :: O1,Game Stats :: $O2:$O83), which returns the first value in column O. How do I adjust the formula to only return the final cell (currently at O26)?

Dec 2, 2011 2:29 PM in response to Trey Hill

Create a column next to "O" - column "P". Enter 0 in P1.


Enter =IF(ISBLANK(O2),"",P1+1) in P2. Fill down as far as you need to go. This will give a column of numbers that increments by 1 and stops at the first blank cell.


Enter =MAX(P1:P100) to find the highest number in this column.


Use that number in your lookup formula to find the corresponding number in column "O".


Hope that helps! (Barry will probably have a more elegant solution!)

Dec 2, 2011 2:48 PM in response to John De Banzie

Okay, so this is a stats spreadsheet for hockey. I've come up with a handful of statistical paramaters on which to measure a player & so, on each player sheet, I fill in the stats for each game (there are 82 in a season). The stats are weighted & scored - and column O holds a rolling 5 game average score, which I would like to pull forward onto the summary sheet.


Obviously, here at game 26 of the season, there are a lot of blanks in column O & I just need the latest rolling average. For obvious reasons, I'd like to find a formula that allows me to fill in the stats on each players page (25 or so players) and then the summary sheet would be automatically updated.


John, in your solution above, I'm not sure why it wasn't liking my numbers w/ decimals, but a value of 4.6 throws an error. Also, the first 4 games don't have a rolling 5 game average, so right from the get go, it's blanking out.


Hoping Barry has something, as you say, elegant.

Dec 2, 2011 6:28 PM in response to Trey Hill

Hi Trey,


Thanks for the clarification of the issue. Once all the details were there, I was sure the solution would fall into place before long, probably before I returned from my 'afternoon chores.'


Given that every cell in column O that is above the target cell contains a numerical value, Jerry's solution and mine would be essentially identical.


But the comment in your reply to John, "the first 4 games don't have a rolling 5 game average, so right from the get go, it's blanking out," leads me to wonder if these first four rows also throw Jerry's count off?


Taking Jerry's example, and moving the supplied data down to leave four empty cells (representing the first four games, where there's yet to be a rolling average), I get this result:


Data table on the left. Summary table on the right with Jerry's unmodified formula in A2

User uploaded file

Count & Offset::A2: =OFFSET(Data :: B1,COUNT(Data :: $B),0)


The formula correctly counts the cells containing numerical data in column B of the Data table (5), then returns the result from the cell that is offset 5 rows (down) and 0 columns (right) from the top cell in that column (B1). The result is the 5 from the yellow-filled cell. The expected result is the 2 in the green-filled cell, four rows below.


One way to make the formula return the value from the correct cell is to enter (countable) dummy data into the four empty cells (B2::B5). Another is to revise the formula in one of the two manners below.


In Count & Offset::B2, the formula is revised to include a constant (4) to account for the four empty cells before the first rolling average:


Count & Offset::B2: =OFFSET(Data :: B1,COUNT(Data :: $B)+4,0)


In Count & Offset::C2, OFFSET's base cell is changed to reference the cell above the one containing the first rolling average:


In Count & Offset::C2 =OFFSET(Data :: B5,COUNT(Data :: $B),0)


Regards,

Barry

Dec 2, 2011 7:14 PM in response to John De Banzie

Hi John,


You've got the start of a working solution there. You first formula creates an index, and the second (not shown in your post) uses the maximum value as a search-for value to find the target cell in column O.


It's main problem is that the arithmetic operators, +, -, * and /, choke on non-numeric values, so as Trey noted, the formula fails on the first rows where column O contains empty cells. Instead of using + and referencing a specific cell (which might contain text—including the possibility of a null string), use MAX, which treats text values as zeros.


P2 (original): =IF(ISBLANK(O2),"",P1+1)


P2 (revised): =IF(ISBLANK(O2),"",MAX($P$1:P1)+1)


Here's the result, using mostly the data from the previous example, but changing one of the 'averages' to a zero, placing a null string in the next row, and leaving the next cell empty. (See the labels in column A) Cell references in the formulas above have been changed to use the data column (B instead of O) and Index column (C instead of P) in the sample table. The LOOKUP formula is shown at the top of the image.

User uploaded file


This method is a bit more robust than the one using COUNT and OFFSET in that it will return the value from the "last cell in the column containing a value" no matter what type of value that cell contains, and without regard to whether cells above it are empty or contain values of any type.


For Trey's case, where no cells other than the known 4 at the beginning are empty of contain non-numeric values, this method will work, but provides no visible advantage over using COUNT and OFFSET.


Regards,

Barry

finding the final cell with a value in a specific column?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.