ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Add only cells whose contents are in "Bold" (https://www.excelbanter.com/excel-discussion-misc-queries/221883-add-only-cells-whose-contents-bold.html)

oisinirish

Add only cells whose contents are in "Bold"
 
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?

Don Guillett

Add only cells whose contents are in "Bold"
 
Sub sumbold()
For Each c In Range("a2:a22")
If c.Font.Bold = True Then ms = ms + c
Next c
MsgBox ms
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"oisinirish" wrote in message
...
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?



curlydave

Add only cells whose contents are in "Bold"
 
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")

Rick Rothstein

Add only cells whose contents are in "Bold"
 
How did the values get to be bold... manually or via Conditional Formatting?
If Conditional Formatting, what formula was used to make them bold?

--
Rick (MVP - Excel)


"oisinirish" wrote in message
...
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?




All times are GMT +1. The time now is 10:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com