View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel.programming,microsoft.public.excel.misc
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default SUM if cell is Bold

Hi Steve,

I think you need to use a User Defined Function to do 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

To get the code in place...

1. Copy it

2. In Excel go Tools|Macro|"Visual Basic Editor" or press Alt + F11 to
get into the Visual Basic Editor

3. In the Visual BAsic Editor go Insert|Module then paste the code into
the module that appears.

4. Save then go File|"Close and Return to Microsoft Excel" to get back
to Excel

5. If your Security is set at High or Very High change it to Medium by
going Tools|Macro|Security... then select Medium. Then close and reopen
and click on "Enable Macros" on the "Security Warning" dialog. UDF's
don't work unless security is Medium or Low.

Ken Johnson