Microsoft Office Tutorials and References
In Depth Information
Some Useful Worksheet Functions
Function FillColor(cell) As Integer
‘ Returns an integer corresponding to
‘ cell’s interior color
FillColor = cell.Range(“A1”).Interior.ColorIndex
End Function
A talking worksheet
The SayIt function uses Excel’s text-to-speech generator to “speak” it’s argument (which can
be literal text or a cell reference).
Function SayIt(txt)
Application.Speech.Speak (txt)
SayIt = txt
End Function
This function has some amusing possibilities, but it can also be useful. For example, use the
function in a formula like this:
=IF(SUM(A:A)>25000,SayIt(“Goal Reached”))
If the sum of the values in column A exceeds 25,000, you’ll hear the synthesized voice tell you
that the goal has been reached. You can also use the Speak method at the end of a lengthy
procedure. That way, you can do something else, and you’ll get an audible notice when the
procedure ends.
Displaying the date when a file was saved or printed
An Excel workbook contains several built-in document properties, accessible from the
BuiltinDocumentProperties property of the Workbook object. The following function
returns the date and time that the workbook was last saved:
Function LastSaved()
Application.Volatile
LastSaved = ThisWorkbook. _
BuiltinDocumentProperties(“Last Save Time”)
End Function
The date and time returned by this function are the same date and time that appear in the
Related Dates section of Backstage View when you choose File➜Info. Note that the AutoSave
feature also affects this value. In other words, the “Last Save Time” is not necessarily the last time
the file was saved by the user.
 
Search JabSto ::




Custom Search