Excel formula to show above and below row in the next column

mar_luna

New Member
Joined
Dec 4, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have tried several formulas and I cant find a way around.
I need to show/filter and above and below row from one cell . I need to do this in the next column.
I have a formula that is called gap and if the cell is YES, the in the next column I have to do a formula that shows the row above and below YES. hopefully, my explanation make sense. Any help will be highly appreciated it,

1733374368854.png
 

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.
Welcome to the MrExcel board!

For the future, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.
(If you have trouble with XL2BB, review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of the XL2BB Instructions page linked above.)

Is one of these what you are after?

mar_luna.xlsm
ABCD
1
2
3
4StepGAPShowShow2
56.76  
68.47showshow
74.96YES  
85.17showshow
94.16  
100.32showshow
117.98YESshow 
123.44YESshow 
138.62showshow
140.89  
157.18  
162.03showshow
174.16YES  
180.32showshow
197.98YES  
203.44showshow
218.62  
22
23
Sheet1
Cell Formulas
RangeFormula
C5:C21C5=IF(OR(B4="YES",B6="YES"),"show","")
D5:D21D5=IF(AND(OR(B4="YES",B6="YES"),B5<>"YES"),"show","")
 
Upvote 0
Welcome to the MrExcel board!

For the future, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.
(If you have trouble with XL2BB, review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of the XL2BB Instructions page linked above.)

Is one of these what you are after?

mar_luna.xlsm
ABCD
1
2
3
4StepGAPShowShow2
56.76  
68.47showshow
74.96YES  
85.17showshow
94.16  
100.32showshow
117.98YESshow 
123.44YESshow 
138.62showshow
140.89  
157.18  
162.03showshow
174.16YES  
180.32showshow
197.98YES  
203.44showshow
218.62  
22
23
Sheet1
Cell Formulas
RangeFormula
C5:C21C5=IF(OR(B4="YES",B6="YES"),"show","")
D5:D21D5=IF(AND(OR(B4="YES",B6="YES"),B5<>"YES"),"show","")
Thank you so much Peter. I'm going to explain myself better.
1. I can't install XL2BB (work computer)
2. I have a table with more than 500,000 rows.
3. I need to show the rows above and below YES. Please note that this is NOT the order, I have the "YES" in several other random cells.

Something like this:

1733379240967.png
 
Upvote 0
1. I can't install XL2BB (work computer)
Fair enough. In any future threads you start, tell us that in the first post so we don'y keep asking. ;)

Something like this:
You did not give an example of what you want if 2 or more cells in a row have "YES". Is that possible with your data?

Something like this:
In what way do my formulas in my previous post fail for you? Both of them provide those exact results for the sample that you have now given.

mar_luna.xlsm
ABC
1GAPShowShow2
2ShowShow
3YES  
4ShowShow
5  
6ShowShow
7YES  
8ShowShow
9
10
Sheet1
Cell Formulas
RangeFormula
B2:B8B2=IF(OR(A1="YES",A3="YES"),"Show","")
C2:C8C2=IF(AND(OR(A1="YES",A3="YES"),A2<>"YES"),"Show","")
 
Last edited:
Upvote 0
Fair enough. In any future threads you start, tell us that in the first post so we don'y keep asking. ;)


You did not give an example of what you want if 2 or more cells in a row have "YES". Is that possible with your data?


In what way do my formulas in my previous post fail for you? Both of them provide those exact results for the sample that you have now given.

mar_luna.xlsm
ABC
1GAPShowShow2
2ShowShow
3YES  
4ShowShow
5  
6ShowShow
7YES  
8ShowShow
9
10
Sheet1
Cell Formulas
RangeFormula
B2:B8B2=IF(OR(A1="YES",A3="YES"),"Show","")
C2:C8C2=IF(AND(OR(A1="YES",A3="YES"),A2<>"YES"),"Show","")
Hi Peter,

It doesn't. Thanks for your help I managed to did myself.
 
Upvote 0

Forum statistics

Threads
1,224,738
Messages
6,180,673
Members
452,993
Latest member
FDARYABEE

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