mercredi 31 août 2016

MS Excel- Populate cell with a percentage based on number of cells coloured?

I'm looking to populate a cell value with a number based on how many cells have the colour green.

example 1:

A1 B1 C1 D1 (E1- Answer '15%' will appear here)
G  NG NG NG (G= Green, NG= Not Green)

Another example:

A1 B1 C1 D1 (E1- Answer '30%' will appear here)
G  G  NG NG (G= Green, NG= Not Green)

=IF(GetFillColor(A1)=4,"1",AND IF(GetFillColor(A1:B1)=4,"2"), AND IF(GetFillColor(A1:C1)=4,"3"), AND IF(GetFillColor(A1:C1)=4,"4", "0"))

GetFillColour:

 Function GetFillColor(Rng As Range) As Long
    GetFillColor = Rng.Interior.ColorIndex
 End Function

Any help would be much appreciated, Thanks!

Aucun commentaire:

Enregistrer un commentaire