Worksheet formulas

B

Bob Phillips

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)
 
R

ryguy7272

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---
 
B

Bob Phillips

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)
 
Top