问题描述
我在excel 2013中使用了带有以下语法的评估数组函数。
I am using evaluate array function in excel 2013 with below Syntax.
= MAX(IF(DPR! B:B = DPR!B2,DPR!F:F))
=MAX(IF(DPR!B:B=DPR!B2, DPR!F:F))
在Excel中,它工作正常,但如果我在Excel VBA中使用相同的公式,它会给我相同的重复值细胞。
In excel it's working fine but if I am using same formula in Excel VBA , it gives me same repeated value in all the cells.
r =评估(" = MAX(IF(DPR!B:B = DPR!B2,DPR!F:F))")
r = Evaluate("=MAX(IF(DPR!B:B=DPR!B2, DPR!F:F))")
任何想法...
推荐答案
可能需要让我们更多地了解周围的函数调用以及如何从工作表中调用它:
Probably need to let us know a little more about the surrounding function call and how you are calling it from the worksheet:
1)是否将r声明为变量? (例如:Dim r作为变体)你是否正在处理r,好像它是一个数组,无论上述语句发生在什么例程中?
1) Is r declared as a variant? (e.g: Dim r as variant) and are you handling r as though it is an array in whatever routine the above statement occurs?
2)你使用这一行是一个函数吗?此函数是否返回类型变体?例如
Public Function MyMaxFunctin()作为变体?如果它不是一个数组而你已经将该函数用作数组调用,那么你将重复获得相同的值。
2) Are you using this line is a function? Does this function return a type variant? e.g.
Public Function MyMaxFunctin() as variant? If it is anything other than an array and you have used the function as an array call, you will just get the same value repeatedly.
3)你正在调用它自己的单元格中的函数并且它不作为数组输入,而是作为单个单元格输入。
3) You are calling the function in it's own cell and it is not entered as an array but as individual cells.
例如A2中的公式是= MyFunction()和A3 = MyFunction(),而不是在A2和&中看到公式。 A3为{= MyFunction()}
e.g. Formula in A2 is =MyFunction() and A3 =MyFunction() instead of seeing the formulas in A2 & A3 as {=MyFunction()}
这篇关于Excel 2013 VBA评估功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!