Excel's CELL( ) function is a little-used feature that offers a tremendous amount of information regarding the formatting, location, or contents of a cell. Table 1 displays the information available from using the CELL( ) function.
|
Information Type |
Returns |
|
ADDRESS |
Reference of the first cell in reference, as text. |
|
COL |
Column number of the cell in reference. |
|
COLOR |
The value 1 if the cell is formatted in color for negative values; otherwise returns 0 (zero). |
|
CONTENTS |
Value of the upper-left cell in reference; not a formula. |
|
FILENAME |
Filename (including full path) of the file that contains reference, as text. Returns empty text ("") if the worksheet that contains reference has not yet been saved. |
|
FORMAT |
Text value corresponding to the number format of the cell. The text values for the various formats are shown in the following table. Returns "-" at the end of the text value if the cell is formatted in color for negative values. Returns "()" at the end of the text value if the cell is formatted with parentheses for positive or all values. |
|
PARENTHESES |
The value 1 if the cell is formatted with parentheses for positive or all values; otherwise returns 0. |
|
PREFIX |
Text value corresponding to the "label prefix" of the cell. Returns single quotation mark (') if the cell contains left-aligned text, double quotation mark (") if the cell contains right-aligned text, caret (^) if the cell contains centered text, backslash (\) if the cell contains fill-aligned text, and empty text ("") if the cell contains anything else. |
|
PROTECT |
The value 0 if the cell is not locked; otherwise returns 1 if the cell is locked. |
|
ROW |
Row number of the cell in reference. |
|
TYPE |
Text value corresponding to the type of data in the cell. Returns "b" for blank if the cell is empty, "l" for label if the cell contains a text constant, and "v" for value if the cell contains anything else. |
|
WIDTH |
Column width of the cell, rounded off to an integer. Each unit of column width is equal to the width of one character in the default font size. |
Figure 1 - Information Returned By Excel's CELL( ) Function
Thus, the following formula returns into a cell the name of the worksheet and workbook in which the cell resides.
=CELL(“filename”,A1)
To modify the formula so that it only returns the worksheet name into the current cell, add the MID( ) and FIND( ) functions as shown below.
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
Using Excel’s CELL( ) function, you can gather and display significant relevant information about the contents of a cell or range of cells.
