简体   繁体   中英

Format the last cell only with value equal or higher than X

How do I use conditional formatting to format only the last cell in each column with a minimum value ?
This implies a non-VBA solution.

I have tried using this formula, but it stops after first match (5 is formatted):

AND(A2>=5,COUNTIF($A$2:A2,">=5")=1)

Using this data, only 9 should be formatted.

Data :

1
2
3
4
5  <-- actual result
6
7
8
9  <-- expected result

UPDATE:
This formula seems to do the trick, but only works when the cell values in the range are numeric, which mine are, and only in 1 column. Range must match format area.
Note: I found the "INDEX..E+307" part somewhere else, but lost the URL so cant give credit.

AND(A2>=5,A2=INDEX($A$2:A10,MATCH(9.99999999999999E+307,$A$2:A10)))

A multi-column supported formula is now needed. Using OFFSET might be the way to go..

I'm reading the problem as this:

We want to highlight the last cell in the column, but only when the cells in that column contain at least one sufficiently large value.

Assuming data starts in A1 , I came up with this:

=AND(COUNTIF(OFFSET(A$1,,,COUNT(A:A),1),">=5")>0,ROW()=COUNT(A:A))

There are some assumptions there: like we can say that the number of non-empty values can be counted by COUNTA() , or that data starts in row 1 so that we can find the last row with ROW()=COUNT(A:A) . But hopefully you get the idea...

If you are in fact looking for the greatest value, not the last one, then this be a starting point:

AND(A2>=5,A2=MAX($A$2:A10))

That should work to locate the highest value across multiple columns as well. If your table can grow over time then you should look at defining the range with an OFFSET() formula.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM