VBA中的函数没有特殊类型。我很难理解如何在Excel VBA中将函数作为参数添加到函数中。
我想要实现的东西是这样的:
function f(g as function, x as string) as string
f = g(x)
end function
目前,我有一组小函数,它们都在重复自己,但只调用了一个特定的函数。
发布于 2012-11-21 16:30:33
由于VBA源于一种交互式语言,因此它始终具有执行文本的能力:
function f(g as string, x as string) as string
f = application.run(g,x)
end function
MyStringA = f("functionA",string1)
MyStringB = f("functionB",string1)
编辑并添加:我认为在当前版本的Excel中,应用程序(Excel)只能“运行”您可以在电子表格单元格中显示的内容。所以这意味着函数,而不是子例程。要执行子例程,请将其包装在函数包装器中:
function functionA(x as string)
Call MySubA(x)
end function
https://stackoverflow.com/questions/1118344
复制相似问题