Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a spreadsheet that will default with values of "No". Over time, these values will be changed to "Yes".

I need a formula (no VB, please, VB is useless to me) that will get me the row number of the last "Yes" in a range of cells so that I can look up the value in that row number of another column to retrieve text to display.

Let's say I have this in one column (call it 1): "Yes", "Yes", "Yes", "No", "No"

And this in the referenced column (call it 2) 1, 1, 2, 2, 3

When all is said and done, INDIRECT(THE_FORMULA_HERE, 2) should retrieve me the value "2". And when all "Yes" are placed, it would change to "3", etc.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Assuming the data is contiguous (i.e. "Yes, Yes, Yes, No, No" but not "Yes, Yes, No, Yes, No") then you can use the following formula:

=INDIRECT("B" & (COUNTIF(A2:A6, "Yes")+1))

This is the data I used:

   | A      B
---------------
 1 | Yes    1
 2 | Yes    1
 3 | Yes    2
 4 | No     2
 5 | No     3

There are other ways to do it if you can add a sequence column, then use COUNTIF and VLOOKUP to do the same thing.

share|improve this answer
    
Thank you sir, that's exactly what I needed. Yes, the data is contiguous. –  MetroidFan2002 Nov 1 '09 at 17:38
1  
How did you format the table like that that's nice :) –  asksuperuser Nov 1 '09 at 17:44
    
@metroidfan2002 not a problem, glad I could help –  Richard Slater Nov 1 '09 at 19:22
    
@asksuperuser it is in a code block (four spaces before the first character of each line) then just use spaces to "tab" the characters to the correct position. Spent most of my formative programming years bugging people in IRC, that is the easiest way to display simple 2D datasets. –  Richard Slater Nov 1 '09 at 19:24

I'd use INDEX rather than INDIRECT as it is non-volatile, but the concept would be almost identical if all the Yes answers are contiguous and not split by No's.

=INDEX(B1:B100,COUNTIF(A1:A100,"Yes"))

With 100 replaced by however many rows you really have

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.