View Single Post
  #3   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Fri, 11 Mar 2005 11:37:06 -0800, "wanda"
wrote:

Hi!
I need to get a total from a worksheet that has hundreds of amounts in it.
However, I only need the total of the amounts that were marked with have BOLD
font. Please help me I don't have much experience with EXCEL.

Thank you very much!

W a n d a


You will need to use a User Defined function written in VBA in order to do
this. But two caveats:

1. The formula will NOT recalculate if all you do is change the font attribute
of any cells in the target.

2. If the BOLD is due to conditional formatting, this UDF will not work.
However, you would be able to use a worksheet formula using the same condition.

3. As written, if a Value in the range is BOLD but is NOT a number, you will
get a #VALUE! error

To enter this UDF, <alt-F11 opens the VB Editor. Ensure your project is
highlighted in the Project Explorer window, then, from the top menu bar of the
VB Editor, select Insert/Module and paste the code below into the window that
opens.

To use the UDF, enter =SUMBOLD(rg) into some cell where rg is the range of
cells that you wish to scan for bold cells and sum them.

========================
Function SumBold(rg As Range) As Double
Application.Volatile
Dim c As Range

For Each c In rg
If c.Font.Bold = True Then
SumBold = SumBold + c.Value
End If
Next c

End Function
==========================



--ron