Worksheet formulas

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What formula enables me to count the number of cells with a specific format?
 
None.

Function CountEm(rng as range, cellFormat as string)
Dim cell As Range
For each cell in rng
If cell.numberformat = cellformat Then
CountEm = CountEm + 1
End If
Next cell
End Function

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Hey Bob! I just noticed your code. I copied/pasted it into a VBA module and
tried to get it working, but was unable to do so. I tried the version that
Chip Pearson posed on his site:

http://www.cpearson.com/excel/colors.htm

This works well for me, but yours does not.

I colored cells A1:A2 & A4:A6, and colored cell C1 the same color (cells
A3:A4 are white).Then I placed =countem(A1:A6,C1) in E1 and I expected to see
a value of 4, but instead I got a value of 6. If you get a chance, please
explain how to ‘call’ your function.

Regards,
Ryan---
 
This was not for cell colour, but cell formats.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top