Microsoft Office Tutorials and References
In Depth Information
Function CELLFORMULA(cell As Range) As String
If cell.Range(“A1”).HasFormula Then
CELLFORMULA = cell.Range(“A1”).Formula
CELLFORMULA = “”
If you don't require compatibility with versions prior to Excel 2013, you can use the new
FORMULATEXT function instead of this custom function.
Is the cell hidden?
The following CELLISHIDDEN function accepts a single cell argument and returns TRUE if the cell is hidden.
A cell is considered a hidden cell if either its row or its column is hidden.
Function CELLISHIDDEN(cell As Range) As Boolean
‘ Returns TRUE if cell is hidden
Dim UpperLeft As Range
Set UpperLeft = cell.Range(“A1”)
CELLISHIDDEN = UpperLeft.EntireRow.Hidden Or _
Using the functions in this chapter
If you see a function listed in this chapter that you find useful, you can use it in your own workbook. All the Func-
tion procedures in this chapter are available at this topic's website. Just open the appropriate workbook, activate
the VB Editor, and copy and paste the function listing to a VBA module in your workbook. If you prefer, you can
collect a number of functions and create an add-in (see Chapter 24 for details).
It's impossible to anticipate every function that you'll ever need. However, the examples in this chapter cover a
wide variety of topics, so it's likely that you can locate an appropriate function and adapt the code for your own
Returning a worksheet name
The following SHEETNAME function accepts a single argument (a range) and returns the name of the work-
sheet that contains the range. It uses the Parent property of the Range object. The Parent property returns an ob-
ject — the worksheet object that contains the Range object.