我可以在Excel中按名称调用UDF函数吗?

时间:2022-10-11 03:22:30

I'm teaching my students to write UDF's in Excel, and have had them submit an Excel add-in with their functions in a module. They all have standard function names and input variables. I'm trying to find a way to easily write some function calls that should return known solutions, then disable my add-in, and enable each student's add-in to see if their code works as it should.

我教我的学生用Excel编写UDF,并让他们在一个模块中提交一个Excel插件。它们都有标准的函数名和输入变量。我正试图找到一种方法来轻松地编写一些函数调用,这些调用应该返回已知的解决方案,然后禁用我的外接程序,并启用每个学生的外接程序,以查看他们的代码是否正常工作。

However, when I disable my add-in, the functions that I create change to reference my add-in file directly, so when I then enable the student's add-in, the functions don't reference the student's add-ins as I want them to.

然而,当我禁用外接程序时,我创建的函数会直接引用我的外接程序文件,所以当我启用这个学生的外接程序时,函数不会像我希望的那样引用学生的外接程序。

Does anyone know how I could accomplish this without retyping the test equations for each student's work?

有没有人知道我怎样才能做到这一点,而不需要对每个学生的作业重新输入测试方程?

Thanks!

谢谢!

1 个解决方案

#1


1  

Instead of using your own add-on, can you add your functions to your personal.xlsb workbook and add each student's to the test workbook in turn? Then you can reference your functions as

你可以将你的功能添加到你的个人电脑中,而不是使用你自己的附加功能。xlsb作业本并将每个学生的作业本依次添加到作业本中?然后可以引用函数as

=PERSONAL.XLSB!TESTFUNCTION()

and your students' functions as

你的学生的功能是

=TESTWORKBOOK.XLSX!TESTFUNCTION()

The cells referencing your personal workbook will always reference your own formulas. For each student, just copy and paste each module they have created into the test workbook and Excel should then pick them up.

参考个人工作簿的单元格将始终引用您自己的公式。对于每个学生,只需将他们创建的每个模块复制并粘贴到测试工作簿中,然后Excel就会将它们提取出来。

Of course, you will need to copy and paste over the last student's work, so this won't work if you want to compare every student to every other.

当然,你需要复制和粘贴上一个学生的作业,所以如果你想要将每个学生和其他学生进行比较,这是行不通的。

#1


1  

Instead of using your own add-on, can you add your functions to your personal.xlsb workbook and add each student's to the test workbook in turn? Then you can reference your functions as

你可以将你的功能添加到你的个人电脑中,而不是使用你自己的附加功能。xlsb作业本并将每个学生的作业本依次添加到作业本中?然后可以引用函数as

=PERSONAL.XLSB!TESTFUNCTION()

and your students' functions as

你的学生的功能是

=TESTWORKBOOK.XLSX!TESTFUNCTION()

The cells referencing your personal workbook will always reference your own formulas. For each student, just copy and paste each module they have created into the test workbook and Excel should then pick them up.

参考个人工作簿的单元格将始终引用您自己的公式。对于每个学生,只需将他们创建的每个模块复制并粘贴到测试工作簿中,然后Excel就会将它们提取出来。

Of course, you will need to copy and paste over the last student's work, so this won't work if you want to compare every student to every other.

当然,你需要复制和粘贴上一个学生的作业,所以如果你想要将每个学生和其他学生进行比较,这是行不通的。