Search code examples
if-statementgoogle-sheetsgoogle-sheets-formulags-conditional-formatting

Highlight row with highest cell value within dynamic range


I want to highlight the cells in a Google Spreadsheet with the highest values based on a dynamic range.

I've got two columns: column K and column L. Column K contains sums of data, column L contains either 'Yes', 'No' or 'Maybe'.

I want to use conditional formatting to highlight the rows with the highest value in column K AND which contain 'Yes' in column L (so, the highest value in column K is only calculated from the rows that contain 'yes' in column L as well). It is possible that there's multiple highest values that have 'Yes'. So while the absolute highest value in the whole of column K can be found on (for example) K100, and the second-highest is found on K59, if L100 doesn't include 'Yes' on column L but L59 does, row 59 will be highlighted.

I've got this code for highlighting whenever L is equal to 'Yes':

=$L:$L = "Yes"

And this code for highlighting the highest value in column K:

=$K5=MAX($K$5:$K$999)

But I have to combine them somehow.

I think that some kind of IF- or AND-statement will be the solution, but I don't know how to dynamically call on the range I need. The position of the Yes'es change based on other values and are not necessarily below each other. For instance:

=IF($L:$L="Yes";MAX($K1;$K3;$K4;$K9))

Where '$K1;$K3;$K4;$K9' represents the dynamic range.


Solution

  • try like this for range A5:Z:

    =($L5="Yes")*($K5=MAX($K$5:$K))