VBA-通过计算负值来排名最高到最低? [英] VBA - Ranking Highest to Lowest by Counting Negative Values?
本文介绍了VBA-通过计算负值来排名最高到最低?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过计算负值将排名从高到低排序?
How to rank highest to lowest by counting negative values?
我可能会使用类似ifelif的逻辑,但是我似乎无法弄清楚
I would probably use something like this follow by if elseif logic but I can't seems to figure it out
Set CountRng = range("B1:E1")
CountApple = Application.WorksheetFunction.CountIf(CountRng, "<0")
CountOrange ..
CountBanana ..
If CountApple > CountOrange then or endif...
也许有更好的方法可以做到这一点?
Maybe there is a better way to do this?
推荐答案
您可以使用以下公式:
=SUMPRODUCT(--(COUNTIF(OFFSET($B$1,(ROW($1:$3)-1),0,1,4),"<0")>COUNTIF(B1:E1,"<0")))+1
这篇关于VBA-通过计算负值来排名最高到最低?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文