Microsoft Office Tutorials and References
In Depth Information
Returning an acronym
The ACRONYM function returns the first letter (in uppercase) of each word in its argument. For example, the
following formula returns IBM:
=ACRONYM(“International Business Machines”)
The listing for the ACRONYM Function procedure follows:
Function ACRONYM(text As String) As String
‘ Returns an acronym for text
Dim TextLen As Long
Dim i As Long
text = Application.Trim(text)
TextLen = Len(text)
ACRONYM = Left(text, 1)
For i = 2 To TextLen
If Mid(text, i, 1) = “ “ Then
ACRONYM = ACRONYM & Mid(text, i + 1, 1)
End If
Next i
ACRONYM = UCase(ACRONYM)
End Function
This function uses the Excel TRIM function to remove any extra spaces from the argument. The first character
in the argument is always the first character in the result. The For-Next loop examines each character. If the
character is a space, the character after the space is appended to the result. Finally, the result converts to upper-
case by using the VBA UCase function.
Does the text match a pattern?
The following function returns TRUE if a string matches a pattern composed of text and wildcard characters.
The ISLIKE function is remarkably simple and is essentially a wrapper for the useful VBA Like operator.
Function ISLIKE(text As String, pattern As String) As Boolean
‘ Returns true if the first argument is like the second
ISLIKE = text Like pattern
End Function
The supported wildcard characters are as follows:
?
Matches any single character
*
Matches zero or more characters
#
Matches any single digit (0–9)
Search JabSto ::




Custom Search