Counting colour cells and containing specified text

BeataG

Registered User.
Local time
Today, 05:05
Joined
Oct 24, 2008
Messages
21
Hello,

Does anybody know how to write a macro (or function, whatever) that will be accurate for counting the number of cells of specified colour (let's say red ones) and containing specified text e.g. "BM".

Cells in my sheet are white or red, while there is three various texts: "BM", "WA" and "WB".

The range is B2:B58

I would like to get three results:
1) number of red cells and with "BM"
2) number of red cells and with "WA"
3) number of red cells and with "WB"

Thank you in advance for you help,
Regards.
 
Thanks for this site I've just looked through( it is quite interesting), but I couldn't find anything that I can use. Maybe I overlooked something...?
 
The site tells you how to handle colours , it will not give the code for your problem.
You want a development of something like

Code:
Private Sub CommandButton1_Click()
Dim counta As Integer
For Each c In Range("B2:B58")
    
     If c.Interior.Color = 255 And c.Value = "xyz" Then counta = counta + 1

    Next c
    
End Sub

This assumes that your RED is 255

Brian
 
Thank you for help. I really appreciate it,
Regards.
 

Users who are viewing this thread

Back
Top Bottom