Total up boldly formatted cells

Closed
TanyaRT Posts 7 Registration date Sunday November 16, 2014 Status Member Last seen August 20, 2015 - Nov 17, 2014 at 06:00 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Nov 22, 2014 at 05:52 AM
Good evening much appreciated volunteers

I am using an Excel 2007 spreadsheet to keep track of costs associated with a holiday.

I have bolded all the expenses which have already been paid and I would be most grateful if some could please assist me in providing a formula or function to total these bolded cells. I have found a VBA code that works, but it does not appear to update as I bold more cells. And as soon as I change any of the data within the cell range, the cell with the sumifbold formula throws out an error: #NAME?

I am not experienced in using VBA code.

Here is the code I used:
Function SumIfBold(MyRange As Range) As Double

Dim cell As Range
For Each cell In MyRange
If cell.Font.Bold = True Then
SumIfBold = SumIfBold + cell
End If
Next cell

End Function

Have I done something wrong? Is there a better way??

Any Suggestions that anyone may offer would be greatly appreciated.

Thank you all in advance
Related:

3 responses

Blocked Profile
Nov 17, 2014 at 07:43 AM
Hello,

i'm no good with VBA scripts but i do know how to create a formula to add cells.

click the cell where you want the total.

type SUM=(A1,B2,B3)

This example is the total of cell A1 + B2 + B3

If you need to do a range for example A1 -> A10 you would use SUM=(A1:A10)
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Nov 19, 2014 at 07:10 AM
Make is a volatile function


Function SumIfBold(MyRange As Range) As Double
Dim cell As Range

Application.Volatile
For Each cell In MyRange
If cell.Font.Bold = True Then
SumIfBold = SumIfBold + cell
End If
Next cell

End Function
0
Thanks Rizvisa1

I updated my spreadsheet as you suggested. The function totals up all the bold cells, however, if I update the format any of the data in the range to bold, the results do not change accordingly.

Should it?

Thanks again for your help; I am grateful.

Tanya
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Nov 22, 2014 at 05:52 AM
if i write in cell A1
=SumIfBold(B2:G10)

if expect the function to update a1, if i modify any cell in range B2:g10
is this not what is happening ?
0