Microsoft Office Tutorials and References
In Depth Information
Returning a worksheet name
Returning a worksheet name
The following SHEETNAME function accepts a single argument (a range) and returns the name of
the worksheet that contains the range:
Function SHEETNAME(rng) As String
‘ Returns the sheet name for rng
SHEETNAME = rng.Parent.Name
End Function
Returning a workbook name
The following function, WORKBOOKNAME, returns the name of the workbook:
Function WORKBOOKNAME() As String
‘ Returns the workbook name of the cell
‘ that contains the function
WORKBOOKNAME = Application.Caller.Parent.Parent.Name
End Function
Reversing a string
The following REVERSETEXT function returns the text in a cell backward:
Function REVERSETEXT(text) As String
‘ Returns its argument, reversed
REVERSETEXT = StrReverse(text)
End Function
Extracting the nth element from a string
The EXTRACTELEMENT function extracts an element from a text string based on a specified
separator character. Assume that cell A1 contains the following text:
123-456-789-9133-8844
The following formula returns the string 9133, which is the fourth element in the string. The string
uses a hyphen (-) as the separator.
=EXTRACTELEMENT(A1,4,”-”)
 
Search JabSto ::




Custom Search