ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Obtaining Sum of Data in Bold Font (https://www.excelbanter.com/excel-discussion-misc-queries/232177-obtaining-sum-data-bold-font.html)

Sum of Bold Numbers

Obtaining Sum of Data in Bold Font
 
I have a set of numbers, some of which are in bold font and others are not.

I want to obtain the sum of the items in bold only, without distotorting the
original data.

Is there a way to do this?

Jacob Skaria

Obtaining Sum of Data in Bold Font
 
Try the below UDF

Suppose the range to be totalled is A1:A10; use the formula

=AddIfBold(C7:C16)

Function AddIfBold(varRange As Range) As Double
For Each cell In varRange
If cell.Font.Bold Then AddIfBold = AddIfBold + cell.Value
Next
End Function

If you are new to VBA; set the Security level to low/medium in
(Tools|Macro|Security). From workbook launch VBE using short-key Alt+F11.
From menu 'Insert' a module and paste the below code. Save. Get back to
Workbook.

If this post helps click Yes
---------------
Jacob Skaria


"Sum of Bold Numbers" wrote:

I have a set of numbers, some of which are in bold font and others are not.

I want to obtain the sum of the items in bold only, without distotorting the
original data.

Is there a way to do this?


Mike H

Obtaining Sum of Data in Bold Font
 
Hi,

Try this UDF. Alt+F11 to open VB editor. Right click 'ThisWorkbook" and
insert module and paste the code below in.

Call with =SumBold(A26:G26)


Public Function SumBold(Rng As Range) As Long
For Each c In Rng
If IsNumeric(c.Value) And c.Font.Bold = True Then
SumBold = SumBold + c.Value
End If
Next c
End Function

Mike
"Sum of Bold Numbers" wrote:

I have a set of numbers, some of which are in bold font and others are not.

I want to obtain the sum of the items in bold only, without distotorting the
original data.

Is there a way to do this?



All times are GMT +1. The time now is 01:15 AM.

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