How to hide rows if a cell value is above a specified value from a different cell?



I have a spreadsheet and part of it looks like this (you can see that cell C4 has 60):

Based on the above cell, C4, which is 60, it will count from 0 up tp what is in C4, like this, in the A column:

How can I make it so that all rows from 61 (A74) are completely hidden, because the number is above what has been entered in cell C4?

So, because in the example here, C4 is 60, I want it to then look like this:


As you can see, the data stops at 60, because cell A74 is higher than the value in C4 (I just deleted it all to make this screenshot, I want to do it either through a formula or conditional formatting so it is done automatically).

How can I achieve this?

Many thanks, and I hope this makes sense.

7 Replies

If by conditional formatting you may use the rule with formula


applied to your entire range and using Fill=White/Font Color=White format


Hi @Sergei Baklan.  Thanks for replying.

Silly question, but what cell would I put it in?  Can it not be done as a formula with an IF, such as:

IF cell value > C4, hide all rows that occur afterwards

I tried this, but nothing changes.



You can see that I have put your formula, with white formatting, to be applied to my entire dataset.

What am I doing wrong?  Many thanks.

best response confirmed by ianwuk (Contributor)

Like this, but in formula it shall be relative reference for the row, not absolute. Other words $A14, not $A$14. And it shall be first (most top left) cell of your range


Please see attached, "not visible" region is in grey.



Thanks so much @Sergei Baklan.  I managed to get it working.

Hi again @Sergei Baklan.

How can I make it so that the formulas in my sheet only apply to the visible data and ignores what is now hidden? 

Is that possible? 


Also, I want to calculate the total amount payable based on the following:

IF repayment number (between 1 and 84) (cells A14 to A97) is less than number of months (cell C4) THEN sum column E (cells E14 to E97), otherwise blank.

My formula looks like this, but it results in an error (#VALUE!), can you help please?




you can not use if to control value of multiple cells. You need to create an array formula. How ever if you want to sum the value of cells depending on a value on another range than you can use SUMIF


=SUMIF($A$14:$A$97,"<"&$C$4, $E$14:$E$97)


basically this formula will check all the cells in A14-A97 range with the value of C4 cell and if the value of the cell is smaller than the value in C4 the value in the correspnding cell in E column will be added to the sum.