The 'Cell' function returns information about the formatting, location, or contents of a cell.
Syntax:
Some examples...
To get the active worksheet name,
=MID(CELL("filename"),FIND("]",CELL("filename"))+1,255)
To get the active workbook name,
=MID(CELL("filename"),FIND("[",CELL("filename"))+1,(FIND("]",CELL("filename"))+1)-FIND("[",CELL("filename"))-2)
To get the path address & workbook name,
=CELL("filename")
To get the path address only,
=MID(CELL("filename"),1,FIND("[",CELL("filename"))-1)
Syntax:
CELL(info_type, [reference])
info_type - This is required field. A text value that specifies what type of cell information you want to return.
reference - This is optional field. The cell that you want information about. If omitted, the information specified in the info_type argument is returned for the last cell that was changed. If the reference argument is a range of cells, the CELL function returns the information for only the upper left cell of the range.
The info_type arguments are listed below,
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.
Some examples...
To get the active worksheet name,
=MID(CELL("filename"),FIND("]",CELL("filename"))+1,255)
To get the active workbook name,
=MID(CELL("filename"),FIND("[",CELL("filename"))+1,(FIND("]",CELL("filename"))+1)-FIND("[",CELL("filename"))-2)
To get the path address & workbook name,
=CELL("filename")
To get the path address only,
=MID(CELL("filename"),1,FIND("[",CELL("filename"))-1)
No comments:
Post a Comment