Bold Formula

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hello,

What formula would i use to add for example a1:a5, but to
only add together cells with a number that is bold? Would
it be sumformat? I've tried but I just can't seem to get it.

I'm using excel 2003.

Thanks
Brian
 
Hi
you need VBA for this. Try the following

=SUMPRODUCT(--(BoldIndex(A1:A5)),A1:A5)
to sum all bold cells within the range A1:A5

Adapt this to your requirements


'---------------------------------------------------------------------
Function BoldIndex(rng As Range) As Variant
'---------------------------------------------------------------------

Dim cell As Range, row As Range
Dim ret_Bold

If rng.Areas.Count > 1 Then
BoldIndex = CVErr(xlErrValue)
Exit Function
End If

For each cell in rng
if cell.font.bold then
ret_Bold = ret_Bold + 1
end if
next
BoldIndex = ret_Bold

End Function
 
Back
Top