VBA - Ranking Highest to Lowest by Counting Negative Values?

人走茶凉 提交于 2019-12-13 08:48:28

问题


How to rank highest to lowest by counting negative values?

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?


回答1:


You could use this formula:

=SUMPRODUCT(--(COUNTIF(OFFSET($B$1,(ROW($1:$3)-1),0,1,4),"<0")>COUNTIF(B1:E1,"<0")))+1



来源:https://stackoverflow.com/questions/56350988/vba-ranking-highest-to-lowest-by-counting-negative-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!