5

How can I reference a cell in the same column in the previous visible row from a filtered range?

braX
  • 11,506
  • 5
  • 20
  • 33
Riko
  • 433
  • 1
  • 6
  • 20

1 Answers1

8

This is very easy if we prepare to do it.

Say we have data like:

enter image description here

The first step is to introduce a "helper" column. In E2 we enter:

=IF(SUBTOTAL(3,A2:A2)=0,MIN($E$1:E1)-1,SUBTOTAL(3,$A$2:$A2))

and copy down:

enter image description here

Now the cool thing about the "helper" column is that no matter how you filter it, it always shows a simple sequential sequence....let's filter for Alice

enter image description here

This means that any cell can:

  1. retrieve the value in column E
  2. subtract 1 from it
  3. use this value in a Index()/Match() formula to retrieve any value in the previous visible row

EDIT#1:

To answer your question, in C5 we enter:

=INDEX($C$2:$C$21,MATCH(E5-1,$E$2:$E$21,0))

and with no filtering C5 will display $391.00
But with Alice filtering C5 will display $446.00

Gary's Student
  • 95,722
  • 10
  • 59
  • 99
  • I tried to use Index/Match, but without a success, how can I find the coordinates of the above cell? For example, in your last image, imagine that c5 needs a reference to its above cell, in this case c2 – Riko Mar 12 '15 at 20:16