Functions in worksheets

S

scampbell

Does anyone know if it is possible to add numbers if they have a certain
format. For example, I have a column of numbers with some in bold format. I
only want to add the ones that are bold. Can that be done? If so, how?
 
G

Gary''s Student

Enter and use this UDF:

Function countbold(r As Range) As Double
countbold = 0
For Each rr In r
If rr.Font.FontStyle = "Bold" Then
countbold = countbold + rr.Value
End If
Next
End Function


just be careful of volitility issues if you change fonts afterwards.
 
Top