# how to use SUMIF to add the values of a column that are bolded

I have a column of numbers (say, A1 to A500).  Some of the numbers are in bold.  How can I calculate the sum of the numbers in bold?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
I am not sure if you can do this via a Formula but you can definitely achieve it via VBA. Would a user defined function do?

Sid
Author Commented:
Actually, it's probably not worth the trouble.  I can do the work by hand, but thought there might be a simple way to achieve it through SUMIF.  Thanks anyway...
Commented:
Ok. I just wrote the code in case you want it, let me know I will post it :)

Sid
Commented:
Since I already wrote it, here it is :)

Paste this in a module

``````'~~>USAGE =SumBold(A1:A10)
Public Function SumBold(Rng As Range) As Variant
Dim aCell As Range, nSum As Double
Application.Volatile

On Error GoTo Whoa

For Each aCell In Rng.Cells
With aCell
If .Font.Bold Then nSum = nSum + .Value
End With
Next
SumBold = nSum
LetsContinue:
On Error GoTo 0
Exit Function
Whoa:
MsgBox Err.Description
Resume LetsContinue
End Function
``````

So if Cells A1 to A10 have some bold cells then type this in Cell B1

=SumBold(A1:A10)

and you will get the sum :)

Sid

Experts Exchange Solution brought to you by