none
How to achieve parameter hints RRS feed

  • Question

  • I'm starting to develop Excel AddIn in C# on VS and now i have problem,i have a user define formula,but how to achieve parameter hints when i input the user define formula in excel?
    Monday, September 14, 2015 9:32 AM

Answers

  • ​>>>i have a user define formula,but how to achieve parameter hints when i input the user define formula in excel?

    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 = "EXTRACTELEMENT"
       FuncDesc = "Returns the nth element of a string that uses a separator character"
       Category = 14 'User Defined  category
       ArgDesc(1) = "String that contains the elements"
       ArgDesc(2) = "Element number to return"
       ArgDesc(3) = "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.

    For more information, click here to refer about Application.MacroOptions Method (Excel)

    Wednesday, September 16, 2015 8:20 AM