具有多个 OR 条件的 Countif [英] Countif With Multiple OR Criteria

查看:41
本文介绍了具有多个 OR 条件的 Countif的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计算包含特定值的列中的单元格数量.我目前正在使用以下代码:

I need to count the number of cells in a column which contain a specific value. I am currently using the following code:

iVal = Application.WorksheetFunction.COUNTIF(Range("A:A"), "SAL")

但是,我现在需要计算有多少个单元格包含其中之一

However, I now need to count how many cells contain either

  • SAL
  • PRE

推荐答案

最快的方法就是做 2 个 COUNTIF:

The quickest way would just be to do 2 COUNTIFs:

iVal = Application.WorksheetFunction.CountIf(Range("A:A"), "SAL") + Application.WorksheetFunction.CountIf(Range("A:A"), "PRE")

这篇关于具有多个 OR 条件的 Countif的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆