简体   繁体   中英

Changing the colour of 1 cell based on other cells (conditionally formatted) colour in that row

I am creating a spreadsheet, I have columns in my table that perform validation checks (columns C to Y) from data from other sheets (uses conditional formatting) with the cells turning green if valid and red if invalid.

I would like column B to be red if any of cells in the same row but in column C to Y are shaded red.

and if they are all green I would like the cell in column B to be green

is it possible to do this with conditional or will I need to create a macro, if so does anyone have any pointers on how this would be approached?

hopefully what I described makes sense, will happily elaborate

any help appreciated

You can use a function-based CF rule to apply the coloring. Eg: this would return True if there are any cells in rng with a red fill as the result of a CF rule (using the DisplayFormat property of each cell)

Function AnyRed(rng As Range)
    Dim c As Range, rv As Boolean
    For Each c In rng.Cells
        If c.DisplayFormat.Interior.Color = 255 Then
            rv = True
            Exit For
        End If
    Next c
    AnyRed = rv
End Function

In your "master" cell apply a default green fill, then apply a CF rule using the formula and have that apply a red fill when the formula returns True.

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