![]() |
Count if - background colour & value
I'm trying to count cells which have a certain background
colour, but which also have a specific value. I'm able to count background colour using this: For Each Rng In inrange.Cells '' If activecell.value <= 52 Then "this bit doesn't work" If OfText = True Then CountbyColour = CountbyColour - (Rng.Interior.ColorIndex = 38) Else 'nothing End If Next Rng End Function But i can't get the function to work if i addin the condition of cell value, as well as background colour. I've also tried leaving the criteria out of the function and enforcing the criteria in the cell by using =IF(A1:B10 <=52,countbycolour(A1:B10,38,TRUE),"0") But it ignores the "<= 52" bit Any suggestions would be much appreciated. Glenn |
Count if - background colour & value
instead of using ActiveCell, which won't change in your loop, use
Rng: For Each Rng In inrange.Cells If Rng.Value <= 52 Then _ If ofText = True Then _ CountbyColour = CountbyColour - _ (Rng.Interior.ColorIndex = 38) Next Rng In article , "Glenn" wrote: I'm trying to count cells which have a certain background colour, but which also have a specific value. I'm able to count background colour using this: For Each Rng In inrange.Cells '' If activecell.value <= 52 Then "this bit doesn't work" If OfText = True Then CountbyColour = CountbyColour - (Rng.Interior.ColorIndex = 38) Else 'nothing End If Next Rng End Function But i can't get the function to work if i addin the condition of cell value, as well as background colour. I've also tried leaving the criteria out of the function and enforcing the criteria in the cell by using =IF(A1:B10 <=52,countbycolour(A1:B10,38,TRUE),"0") But it ignores the "<= 52" bit Any suggestions would be much appreciated. Glenn |
All times are GMT +1. The time now is 08:47 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com