Add only cells whose contents are in "Bold"

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?
 
D

Don Guillett

Sub sumbold()
For Each c In Range("a2:a22")
If c.Font.Bold = True Then ms = ms + c
Next c
MsgBox ms
End Sub
 
C

CurlyDave

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

Rick Rothstein

How did the values get to be bold... manually or via Conditional Formatting?
If Conditional Formatting, what formula was used to make them bold?
 

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