以下で作成したような関数を作成します。関数CompanyNames:
Function CompanyNames(CompanyCode As Integer, Data As Range) As String
CompanyNames = WorksheetFunction.VLookup(CompanyCode, Data, 2, False)
End Function
以下のコードを1回実行すると、関数で引数の説明が表示されます
Sub DescribeFunction()
Dim FuncName As String
Dim FuncDesc As String
Dim Category As String
Dim ArgDesc(1 To 2) As String
FuncName = "CompanyNames"
FuncDesc = "Returns the Company Name"
ArgDesc(1) = "Provide the Company Code"
ArgDesc(2) = "Select Range to lookup"
Application.MacroOptions _
Macro:=FuncName, _
Description:=FuncDesc, _
Category:=Category, _
ArgumentDescriptions:=ArgDesc
End Sub