Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在VBA中使用带有2个以上参数的countif?_Vba_Arguments_Countif - Fatal编程技术网

如何在VBA中使用带有2个以上参数的countif?

如何在VBA中使用带有2个以上参数的countif?,vba,arguments,countif,Vba,Arguments,Countif,我想使用countif语句来计算性别为男性且年龄在15到30岁之间的员工数量(在我的示例中)。我不知道如何在countif语句中添加另一个参数来添加性别限制,因为它只需要两个语句。 这是我的功能代码: Function Calculate(Column_target As Integer, Row_number As Double, Level_of_response As Integer, Column_of_reference As Integer, level_of_reference A

我想使用countif语句来计算性别为男性且年龄在15到30岁之间的员工数量(在我的示例中)。我不知道如何在countif语句中添加另一个参数来添加性别限制,因为它只需要两个语句。 这是我的功能代码:

Function Calculate(Column_target As Integer, Row_number As Double, Level_of_response As Integer, Column_of_reference As Integer, level_of_reference As Integer) As Double

    Sheets("A").Select
    Range(Cells(2, Column_target ), Cells(Row_number , Column_target )).Select

    For i = 3 To Row_number + 1

        If (Level_of_response = 1) Then
        Calculate = (Application.WorksheetFunction.CountIf(Selection, "<31") - Application.WorksheetFunction.CountIf(Selection, "<15")) / (Row_number - 1)

        End If
函数计算(列\u目标为整数,行\u编号为双精度,级别\u响应为整数,列\u引用为整数,级别\u引用为整数)为双精度
表格(“A”)。选择
范围(单元格(2,列\目标)、单元格(行\号,列\目标))。选择
对于i=3至第_行编号+1
如果(响应级别=1),则

Calculate=(Application.WorksheetFunction.CountIf)(选择,您必须求助于
Countifs
,条件不限


另外,您可以将两个数值条件合并为一个(abs((x-(xmin+xmax)/2)<(xmax-xmin)/2)。

存在“无法获取工作表函数类的countif属性”的错误!@Zapata-或。请尝试
Application.CountIfs(…
)而不是
Application.worksheetfunction.CountIfs(…
@Zapata-请在您的问题中发布完整的修订代码。