I want to use the countif statement to calculate the number of employee (in my example) whose gender are Male and their age is between 15 to 30. I am not sure how to add another argument to the countif statement to add the restriction of gender, since it just take 2 statements. Here is my function code:
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
This is the code that I want to add as the 3rd argument to the countif statement.
(Cells(i, Column_of_reference ) = level_of_reference )
' this shows that Gender is male (or female) when level_of_reference is 1 (or 2).