0% found this document useful (0 votes)
347 views2 pages

Add Arguments Description in VBA

This document provides instructions on how to add argument descriptions for user-defined functions in Excel 2010. It demonstrates writing a simple EXTRACTELEMENT function and then using VBA macros to assign the function a description, category, and descriptions for each of its three arguments. Running this macro stores this metadata in the workbook, so the descriptive information will appear in the Function Arguments dialog box when the function is used. However, the descriptions are not displayed in Excel 2007 and will be removed if the file is saved in XLS format.

Uploaded by

cabpcabp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
347 views2 pages

Add Arguments Description in VBA

This document provides instructions on how to add argument descriptions for user-defined functions in Excel 2010. It demonstrates writing a simple EXTRACTELEMENT function and then using VBA macros to assign the function a description, category, and descriptions for each of its three arguments. Running this macro stores this metadata in the workbook, so the descriptive information will appear in the Function Arguments dialog box when the function is used. However, the descriptions are not displayed in Excel 2007 and will be removed if the file is saved in XLS format.

Uploaded by

cabpcabp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

User-Defined Function Argument

Descriptions In Excel 2010


Category: VBA Functions | [Item URL]

One of the new features in Excel 2010 is the ability to provide argument descriptions for
user-defined functions. These descriptions appear in Function Arguments dialog box -which is displayed after you choose a function using the Insert Function dialog box.
Here's a simple (but very useful) user-defined function:
Function EXTRACTELEMENT(Txt, n, Separator) As String
EXTRACTELEMENT = Split(Application.Trim(Txt), Separator)(n - 1)
End Function

Here's a VBA macro that provides a description for the EXTRACTELEMENT function,
assigns it to a function category, and provides a description for each of its three arguments:
Sub DescribeFunction()
Dim FuncName As String
Dim FuncDesc As String
Dim Category As String
Dim ArgDesc(1 To 3) As String
FuncName =
FuncDesc =
character"
Category =
ArgDesc(1)
ArgDesc(2)
ArgDesc(3)

"EXTRACTELEMENT"
"Returns the nth element of a string that uses a separator
7
=
=
=

'Text category
"String that contains the elements"
"Element number to return"
"Single-character element separator"

Application.MacroOptions _
Macro:=FuncName, _
Description:=FuncDesc, _
Category:=Category, _
ArgumentDescriptions:=ArgDesc
End Sub

You need to run this macro only one time. After doing so, the descriptive information is
stored in the workbook (or add-in) that defines the function.
Here's how the function appears in the Function Arguments dialog box:

What about compaatibility with


h earlier verssions?
If the file
f is openeed in Excel 2007,
2
the arg
gument descrriptions are nnot displayed. If you savve
the wo
orkbook as an
a XLS file, the Compatiibility Checkker kicks in and tells youu that the
functio
on descriptio
ons will be removed.
r

You might also like