具有多个标准的VBA CountIFS

时间:2017-03-18 22:43:05

标签: excel vba excel-vba excel-2013 worksheet-function

我有一个VBA程序,它扫描工作表并产生计数,其中单元格C不等于某些颜色,但是第I列设置为一个值。这是程序:

tableView

条件已经改变,我需要添加另一个计数条件的标准,所以我认为这将是一个快速修复添加逗号和标准到最后像这样

yourTableViewName.tableFooterView = UIView(frame: CGRect.zero)

但是 - 现在这总是返回0.在VBA中将辅助条件添加到CountIFS()的正确方法是什么

修改
我要添加的第二个参数也应该是“OR”条件,因此Sheet1!C [6] = Temp OR Perm

编辑2
我试着像这样编辑我的语法

FormulaR1C1 = "=COUNTIFS(Sheet1!C[-2],RC[-2],Sheet1!C,""<>Red"",
Sheet1!C,""<>Blue"",Sheet1!C,""<>Green"",Sheet1!C,""<>Black"",
Sheet1!C,""<>Purple"",Sheet1!C,""<>White"",
Sheet1!C[6],""Temp"")"

但这给了我一个错误

  

应用程序定义或对象定义错误

1 个答案:

答案 0 :(得分:1)

Dim f
f = "=COUNTIFS(Sheet1!C[-2],RC[-2],Sheet1!C,'<>Red'," & _
    "Sheet1!C,'<>Blue',Sheet1!C,'<>Green',Sheet1!C,'<>Black'," & _
    "Sheet1!C,'<>Purple',Sheet1!C,'<>White'," & _
    "Sheet1!C[6],'Temp') + COUNTIFS(Sheet1!C[-2],RC[-2],Sheet1!C,'<>Red'," & _
    "Sheet1!C,'<>Blue',Sheet1!C,'<>Green',Sheet1!C,'<>Black'," & _
    "Sheet1!C,'<>Purple',Sheet1!C,'<>White',Sheet1!C[6],'Perm')"


FormulaR1C1 = Replace(f, "'", """")