Note: The other languages of the website are Google-translated. Back to English
  Sunday, 15 May 2022
  1 Replies
  1.9K Visits
0
Votes
Undo
Hello.
This ExtendOffice article explains how to insert some code into a Module in order to calculate the values of numbers of which are emboldened:
https://www.extendoffice.com/documents/excel/1339-excel-sum-count-bold-cells.html#a3

However, the code ignores decimal places and returns inaccurate results (especially when dealing with small values).

To test it, I populated a number of emboldened cells with a value of "0.5" or less. The code treated them all as "0" and, thus, resulted in a calculation of zero. However, when I entered values of "0.51" and above, all were rounded up to "1", thus - again - completely miscalculating the result.

Does anyone have a fix for this? Code follows.

Function SumBold(WorkRng As Range)
'Update 20131202
Dim Rng As Range
Dim xSum As Long
For Each Rng In WorkRng
If Rng.Font.Bold Then
xSum = xSum + Rng.Value
End If
Next
SumBold = xSum
End Function
6 months ago
·
#2707
0
Votes
Undo
Hi there,

Thanks for the feedback, I already upgate the code in the article.

Please use the code below:


Function SumBold(WorkRng As Range)
'Update 20220516
Dim Rng As Range
Dim xSum As Double
For Each Rng In WorkRng
If Rng.Font.Bold Then
xSum = xSum + Rng.Value
End If
Next
SumBold = xSum
End Function


If you have any further questions, please don't hesitate to let me know.

Amanda
  • Page :
  • 1
There are no replies made for this post yet.

Follow Us

Copyright © 2009 - www.extendoffice.com. | All rights reserved. Powered by ExtendOffice. | Sitemap
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Protected by Sectigo SSL