11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

664<br />

Part VI: Developing Custom Worksheet Functions<br />

The following formula, for example, returns the string Sheet1:<br />

=SHEETNAME(Sheet1!A16)<br />

The Name property<br />

The Name property returns a Name object for a cell or range. To get the actual cell or range<br />

name, you need to access the Name property of the Name object. If the cell or range does not<br />

have a name, the Name property returns an error.<br />

The following Function procedure displays the name of a range or cell passed as its argument.<br />

If the range or cell does not have a name, the function returns an empty string. Note the use of<br />

On Error Resume Next. This handles situations in which the range does not have a name.<br />

Function RANGENAME(rng)<br />

On Error Resume Next<br />

RANGENAME = rng.Name.Name<br />

If Err.Number 0 Then RANGENAME = “”<br />

End Function<br />

The NumberFormat property<br />

The NumberFormat property returns the number format (as a string) assigned to a cell or<br />

range. The following function simply displays the number format for the upper-left cell in a range:<br />

Function NUMBERFORMAT(cell)<br />

NUMBERFORMAT = cell.Range(“A1”).NumberFormat<br />

End Function<br />

The Font property<br />

The Font property returns a Font object for a range or cell. To actually do anything with this<br />

Font object, you need to access its properties. For example, a Font object has properties such<br />

as Bold, Italic, Name, Color, and so on. The following function returns TRUE if the upper-left<br />

cell of its argument is formatted as bold:<br />

Function ISBOLD(cell)<br />

ISBOLD = cell.Range(“A1”).Font.Bold<br />

End Function

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!