use COUNTIF to total BOLD TEXT??

G

Guest

I am auditing a list of subscribers (for their Dental benefit), and
highlighted (in BOLD text) the ones I need to research. I want to count the
cells with BOLD text in a single column. How do I do this?

I looked (believe me, I looked!) all over Microsoft "Help" and did not find
any references for a way to do this. Of course, whenever I use help, I curse
(CURSE, I say!) the MS search algorithm. It is so deficient it drives me
nuts!! Those who have seen my previous posts know this... Can't MS just buy
(or clone) the one Google uses? That one works so well...

It would be nice if their search-for-help- alogrithm told you if you Can't
do somehting - like put nice custom colors as borders on a group of cells, or
merge cells in a shared workbook, or...

Anyway, please tell me if you know of any way to total BOLD text using a
function -I'll use a macro if I have to but they REALLY drive me nuts -
especially since I have so much trouble debugging them. Your help is
appreciated...

Mark Diaz
Boston, MA USA
 
G

Guest

Check out this cool link found after 2 google searches:

http://www.mcgimpsey.com/excel/udfs/sumbold.html

Here's their answer with code, I have not tested it:


One problem is that there are no events that fire when cell formatting is
changed. While using Application.Volatile causes the cell to recalculate any
time a calculation is done on the worksheet, this means that the cell may not
contain a valid value unless a manual calculation (e.g., F9) is performed.

Put this in a regular code module.

'******************************************************
'Purpose: Sum cells with bold formatting applied
'Inputs: vInput - array of one or more input ranges
'Returns: Sum of cells in vInput with bold formatting
'******************************************************
Public Function SumBold( _
ParamArray vInput() As Variant) As Variant
Dim rParam As Variant
Dim rCell As Range
Dim vTemp As Variant

Application.Volatile
On Error GoTo ErrHandler
For Each rParam In vInput
If TypeName(rParam) = "Range" Then
With rParam
For Each rCell In Intersect( _
.Cells, .Cells.Parent.UsedRange)
With rCell
If .Font.Bold Then
If IsError(.Value) Then
vTemp = .Value
Exit For
ElseIf VarType(.Value2) = vbDouble Then
vTemp = vTemp + .Value2
End If
End If
End With
Next rCell
End With
End If
Next rParam
SumBold = vTemp
Continue:
On Error GoTo 0
Exit Function
ErrHandler: 'Check for overflow
If Err.Number = 6 Then SumBold = CVErr(xlErrNum)
Resume Continue
End Function

Thanks to Harlan Grove for pointing out that the .Value2 property was
appropriate to use here, rather than .Value.

=====================

Pretty cool, eh? Anyone want to test this & post results? I don'thave time
right now...

Mark aka Brainless in Boston
 

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

Top