Argument Descriptions for UDF?

Liên hệ QC

ST-Lu!

Love Wingchun
Tham gia
19/8/08
Bài viết
730
Được thích
546
Nghề nghiệp
Xích lô một thời
thưa các sư huynh
Tiểu đệ đang dùng excel 2007 và muốn UDF sẽ gợi ý các đối số khi nhập hàm
ví dụ: ta có hàm tachso
em muốn có gợi ý khi gõ UDF này như sau = Tachso("gia tri can tach")
Em tham khảo trên mạng có bài viết sau nhưng không biết có ứng dụng được 2007 không?

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 = "EXTRACTELEMENT"
FuncDesc = "Returns the nth element of a string that uses a separator character"
Category = 7 'Text 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.

http://spreadsheetpage.com/index.php/tip/user-defined_function_argument_descriptions_in_excel_2010/
 
thưa các sư huynh
Tiểu đệ đang dùng excel 2007 và muốn UDF sẽ gợi ý các đối số khi nhập hàm
ví dụ: ta có hàm tachso
em muốn có gợi ý khi gõ UDF này như sau = Tachso("gia tri can tach")
Em tham khảo trên mạng có bài viết sau nhưng không biết có ứng dụng được 2007 không?



http://spreadsheetpage.com/index.php/tip/user-defined_function_argument_descriptions_in_excel_2010/
E rằng trên Excel 2003 và Excel 2007 sẽ không dùng được cách này, đơn giản vì ở các phiên bản này, MacroOptions Method không có đối số ArgumentDescriptions
Thử thì biết liền chứ gì
(Vậy là biết thêm 1 cải tiến mới trên Excel 2010 nữa rồi... Cảm ơn bạn)
 
Upvote 0
Để làm được việc này trên mọi Excel thì phải lập trình add-in dạng XLL. Như Add-in "Accounting Helper" tôi làm dạng XLL có hình dưới đây.

FuncArgs.jpg
 
Upvote 0
Web KT
Back
Top Bottom