Add only cells whose contents are in "Bold"

  • Thread starter Thread starter oisinirish
  • Start date Start date
O

oisinirish

I'm trying to create a logical equation that will sum the values of cells
within a range only if the contents are bold. Is this possible?
 
Sub sumbold()
For Each c In Range("a2:a22")
If c.Font.Bold = True Then ms = ms + c
Next c
MsgBox ms
End Sub
 
U need a UDF for that,

Public Function SumBold(rngSumRange As Range) As Single
Dim rngCell As Range
For Each rngCell In rngSumRange
If IsNumeric(rngCell.Value) Then
If rngCell.Font.Bold = True Then
SumBold = SumBold + rngCell.Value
End If
End If
Next rngCell
End Function

Place in a regular module

on the worksheet your formula will be

=SumBold(A1:A7")
 
How did the values get to be bold... manually or via Conditional Formatting?
If Conditional Formatting, what formula was used to make them bold?
 
Back
Top