Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 使用带有动态条件的countif函数_Vba_Dynamic_Countif - Fatal编程技术网

Vba 使用带有动态条件的countif函数

Vba 使用带有动态条件的countif函数,vba,dynamic,countif,Vba,Dynamic,Countif,亲爱的女士们、先生们: 在我的代码中,我使用了CountIf语句 Cells(5, 3).Value = Application.WorksheetFunction.CountIf(CR, ">" & yel) 其中: Dim yel As Double yel = Cells(2, 5).Value 以及: 奇怪的是:如果我使用动态标准&yel,代码会给我一个零作为结果。当我使用固定标准>0时,代码会生成正确的数字 谁能告诉我我做错了什么 致以最良好的问候和感谢 沃特我敢打赌

亲爱的女士们、先生们:

在我的代码中,我使用了CountIf语句

Cells(5, 3).Value = Application.WorksheetFunction.CountIf(CR, ">" & yel)
其中:

Dim yel As Double
yel = Cells(2, 5).Value
以及:

奇怪的是:如果我使用动态标准&yel,代码会给我一个零作为结果。当我使用固定标准>0时,代码会生成正确的数字

谁能告诉我我做错了什么

致以最良好的问候和感谢


沃特

我敢打赌这个猜测: 您没有使用英语Excel。您的Excel版本使用,作为小数点。 将yel转换为字符串后会留下一个,但内部引擎只懂英语。。 如果这样做有效,请尝试:

Dim strYel As String
strYel = Replace(CStr(yel), ",", ".")
Cells(5, 3).Value = Application.WorksheetFunction.CountIf(CR, ">" & strYel)

亲爱的科库塞马,你是正确的!非常感谢你的回答。这个解决方案对我来说很好!遗憾的是,引擎没有考虑到我们的十进制分隔符约定!
Dim strYel As String
strYel = Replace(CStr(yel), ",", ".")
Cells(5, 3).Value = Application.WorksheetFunction.CountIf(CR, ">" & strYel)