Counting bold cells in table rows

  • Thread starter Thread starter John
  • Start date Start date
J

John

How do I create a formula to count the number of bold formatted cells in a
row using Excel 2003?
 
Im not sure there is a formula but vba could do just what you need.
Sub countBoldCells()
Const whatColumn = "A"
Const whatSheet = "Sheet1"
Dim xlWS As Worksheet
Dim lastRow As Long
Dim boldCounter As Long

Set xlWS = Worksheets(whatSheet)
lastRow = xlWS.Range(whatColumn & Rows.Count).End(xlUp).Row

boldCounter = 0
For r = 1 To lastRow
If xlWS.Range(whatColumn & r).Font.Bold = True Then
boldCounter = boldCounter + 1
End If
Next
MsgBox "There are " & boldCounter & " bold cells."
End Sub
 
You first need a UDF

Function CountBold(rg As Range) As Long
''originally posted by Ron Rosenfeld
Dim c As Range
For Each c In rg
CountBold = CountBold - c.Font.Bold
Next c
End Function

Usage is: =CountBold(range)


Gord Dibben MS Excel MVP
 

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