View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
DOR
 
Posts: n/a
Default the sum of all bolded numbers

VBA stands for "Visual Basic for Applications". It is a
programming language that can be used to create programs, also called
macros, which can be used to process the data in your spreadsheet and
perform other actions relative to your spreadsheet that you may wish to
automate.

UDF stands for "User Defined Function". You are obviously familiar
with the Excel's built-in functions such as the SUM function.
Sometimes, as in your current problem, the built-in functions may not
do what you want to do. It is possible, using VBA, to develop a new
function that can be invoked from a spreadsheet cell, just as the SUM
function is. You can now put that function in a cell in your worksheet
and it will perform the actions you have coded it to do.

To make this happen, you must store the code of the UDF in a container
called a "module", associated with your workbook. This module is
different from your worksheets. It is accessed through the Visual
Basic Editor (VBE), which is accessed by clicking Alt-F11 with your
spreadsheet open. A description of how to implement UDFs is contained
here

http://www.ozgrid.com/VBA/Functions.htm

and in many other sites on the web - just enter "excel user defined
functions" in Google.

After you have stored a function, such as the one provided by Bob,
appropriately modified with JE's modification, in a module, you can
simply enter the formula for that function in a cell, e.g.
=SumBold(A2:A20) and that formula will provide you with the sum of all
the bolded numbers in the range A2:A20, each time the spreadsheet
recalculates.

Note, however, that a value in some cell must change to cause
recalculation unless you invoke it by pressing F9. Merely changing the
font of a number from unbolded to bolded or vice versa will not cause
recalculation, even with JE's modification.

DOR