本文介绍了如果大于零,则平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图对一列求平均值,但前提是该值大于零.然后,我希望它将信息放在该行的下一个空白单元格中.
I am trying to average a column but only if the value is greater than zero. I then want it to put the information in the next blank cell in that row.
下面的代码作为简单的平均值运行,但是我希望它从上面的单元格中排除任何零值.
The below code was working as a simple Average but I want it to exclude any values of zero from the above cells.
With Range("D2")
.End(xlDown)(2, 1) = _
"=AVERAGE(" & .Address & ":" & .End(xlDown).Address & ")"
End With
我尝试使用以下代码来使它看起来像单元格地址大于零.但这总是给我一个调试错误?
I Tried with the following code to have it as if the cell address is greater than zero. But it keeps giving me an error to debug?
With Range("D2")
.End(xlDown)(2, 1) = _
"=AVERAGEIF(" & .Address & ":" & .End(xlDown).Address & "," & Cell.Address & " > 0," & .Address & ":" & .End(xlDown).Address & ")"
End With
任何帮助都会很棒.
谢谢铝
推荐答案
您的公式语法错误.
您需要创建一个类似
=AVERAGEIF(D2:Dxx, ">0")
所以使用这个
With Range("D2")
.End(xlDown)(2, 1) = _
"=AVERAGEIF(" & .Address & ":" & .End(xlDown).Address & ","">0"")"
End With
这篇关于如果大于零,则平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!