View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

There's nothing built into excel that will sum values based on formatting.

You could use a User defined function, though.

Option Explicit
Function SumBold(rng As Range)

Application.Volatile

Dim myCell As Range
Dim myTotal As Double

myTotal = 0
For Each myCell In rng.Cells
With myCell
If .Font.Bold = True Then
If IsNumeric(.Value) Then
myTotal = myTotal + .Value
End If
End If
End With
Next myCell

SumBold = myTotal

End Function

Be aware that changing formats won't cause excel to recalculate. You could be
one calculation cycle behind. I'd hit the calculate key (F9) before I trusted
the value in the cell.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=sumbold(a1:a10)

You didn't ask, but Chip Pearson has similar routines based on colors. You may
want to look at that, too:

http://www.cpearson.com/excel/colors.htm



mikeburg wrote:

I am trying to come up with a simple cell formula to total or sum
amounts bolded in a column.

Any Ideas?

Thanks from a person needing help.

mikeburg

--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=392229


--

Dave Peterson