Find nearest row above with value?

Fritz23

New Member
Joined
Sep 21, 2023
Messages
6
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Is there a method/formula to find and return a value that is nearest above to the existing row?

I've seen plenty of examples of finding the first case, but I need the nearest.

See the table below for an example. If the "Type" column/cell is blank, then the "Connect Event" cell should look up until it finds the nearest row above that has the Type cell set to "Event", and return the value in Event Name. The challenge is that the number of rows are dynamic and will vary between the events.

Connected EventTypeEvent Name
First EventEventFirst Event
First Event
Second EventEventSecond Event
Second Event
Second Event
Second Event
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Maybe something like this:

Excel Formula:
=IF(B2="Event",C2,TAKE(FILTER($C$2:C2,$C$2:C2<>0),-1))

Book1
ABC
1Connected EventTypeEvent Name
2First EventEventFirst Event
3First Event
4Second EventEventSecond Event
5Second Event
6Second Event
7Second Event
8Second Event
9Second Event
Sheet3
Cell Formulas
RangeFormula
A2:A9A2=IF(B2="Event",C2,TAKE(FILTER($C$2:C2,$C$2:C2<>0),-1))


Edit: One potential issue is if there is an Event Name in Col C without a corresponding Event Type in Col B, it will pick the latest event name either way. I'll have to play with the formula to get around that.
 
Upvote 0
Edit: One potential issue is if there is an Event Name in Col C without a corresponding Event Type in Col B, it will pick the latest event name either way. I'll have to play with the formula to get around that.

Okay, this seems to work better:

Excel Formula:
=TAKE(FILTER($C$2:C2,$B$2:B2="Event"),-1)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,096
Messages
6,123,074
Members
449,093
Latest member
ripvw

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