I am interested in counting a variable (male) in column A and another variable (working) in column B. I want the output to be the total number of times both 'men' and 'working' are displayed together. Any help is highly appreciated. Thanks in advance
Consider the following data
Use the WorksheetFunction.CountIfs method . The following code should return 4
:
Option Explicit
Sub CountMaleWorking()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
Debug.Print WorksheetFunction.CountIfs(ws.Columns("A"), "male", ws.Columns("B"), "working")
End Sub
=COUNTIFS(A:A,"male",B:B,"working")
As GSerg mentioned, no vba but a simple countifs.
Put in C1
=COUNTIFS(A1:A100,"male",B1:B100,"working")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.