Microsoft Office Tutorials and References
In Depth Information
The following FILLCOLOR function returns a value that corresponds to the color of the cell's interior (the cell's
fill color). If the cell's interior is not filled, the function returns 16,777,215 . The Color property values range
from 0 to 16,777,215.
Function FILLCOLOR(cell As Range) As Long
‘ Returns a value corresponding to the cell's interior color
Application.Volatile True
FILLCOLOR = cell.Range(“A1”).Interior.Color
End Function
If a cell is part of a table that uses a style, the FILLCOLOR function does not return the
correct color. Similarly, a fill color that results from conditional formatting is not re-
turned by this function. In both cases, the function returns 16,777,215.
The following function returns the number format string for a cell:
Function NUMBERFORMAT(cell As Range) As String
‘ Returns a string that represents
‘ the cell's number format
Application.Volatile True
NUMBERFORMAT = cell.Range(“A1”).NumberFormat
End Function
If the cell uses the default number format, the function returns the string General.
Determining a Cell's Data Type
Excel provides a number of built-in functions that can help determine the type of data contained in a cell. These
include ISTEXT, ISNONTEXT, ISLOGICAL, and ISERROR. In addition, VBA includes functions such as
The following function accepts a range argument and returns a string ( Blank, Text, Logical, Error, Date, Time,
or Value ) that describes the data type of the upper-left cell in the range:
Function CELLTYPE(cell As Range) As String
Returns the cell type of the upper-left cell in a range
Dim UpperLeft As Range
Application.Volatile True
Set UpperLeft = cell.Range(“A1”)
Select Case True
Case UpperLeft.NumberFormat = “@”
Search JabSto ::

Custom Search