Finding the value of a cell above a cell that meets a condition in a column

rufuxinix

Board Regular
Joined
Jan 23, 2019
Messages
58
Office Version
  1. 2019
Platform
  1. Windows
In an Excel column I need to find the value of a cell that is immediately above.
Example: If I have cell values that end in 5, I want to extract the value of the cell above them.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
What if 5 is in the first cell in the column?
 
Upvote 0
What do you want to do with them after you "extract" them?
 
Upvote 0
What if 5 is in the first cell in the column?
Not sure Excel can handle that without coding?

I used
=IF(RIGHT(A2,1)=5,A1,"")
but it doesn't seem to work.
Maybe I m doing something wrong but can't figure it out.
 
Upvote 0
Let me rephrase my question. I don't know the layout of your data. There are 2 cases.
Case 1 (col A below): Your first data entry is in A2, and that cell ends with "5". Do you want to return the header (one cell above)?
Case 2 (col B below): Your first data entry is in A1, and that cell ends with "5" but there's no cell above. What do you want to return?

Book2
AB
1Header1SomethingEndsWith5
2SomethingEndsWith5
Sheet4
 
Upvote 0
Let me rephrase my question. I don't know the layout of your data. There are 2 cases.
Case 1 (col A below): Your first data entry is in A2, and that cell ends with "5". Do you want to return the header (one cell above)?
Case 2 (col B below): Your first data entry is in A1, and that cell ends with "5" but there's no cell above. What do you want to return?

Book2
AB
1Header1SomethingEndsWith5
2SomethingEndsWith5
Sheet4
 
Upvote 0
If the first row meets the condition it should not return a result, it's an exception.
Thanks.
 
Upvote 0
Re: but it doesn't seem to work.
Meaning what? What do you get as a result?

Excel Formula:
=IF(RIGHT(RC[-1], 1) = "5", R[-1]C[-1], "Nothing")
 
Upvote 0
Re: but it doesn't seem to work.
Meaning what? What do you get as a result?

Excel Formula:
=IF(RIGHT(RC[-1], 1) = "5", R[-1]C[-1], "Nothing")
I get no result at all. I think I might be doing something wrong.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top