Application.Evaluate calls UDF function multiple times

376 views
Skip to first unread message

Shiraz Kamal

unread,
Jul 29, 2016, 6:49:57 AM7/29/16
to Excel-DNA
Hi All,
I have set a UDF function on a cell which will be called upon button click.Following is the VBA method which is executed to call my UDF.
(Application.Range(cell).Formula refers the my UDF function which is defined inside C# class) .
Problem is When i click the button Evaluate method is called once but my UDF function is called twice.

 Sub Evaluate(cell As String)

        Dim Application = ExcelDnaUtil.Application

        Application.Evaluate(Application.Range(cell).Formula)

  End Sub


Regards,
Shiraz


FastExcel

unread,
Sep 6, 2016, 4:10:22 AM9/6/16
to Excel-DNA
You need to use Worksheet.Evaluate rather than Application.Evaluate to avoid this problem. See
https://fastexcel.wordpress.com/2011/11/02/evaluate-functions-and-formulas-fun-how-to-make-excels-evaluate-method-twice-as-fast/

for more details
Reply all
Reply to author
Forward
0 new messages