I have a data range B5:L100.

In column B is a string identifier, say ‘X’ or ‘Y’.

In columns C:L we have different people’s names entered (never more than once per row).

I want to count how many times a person’s name appears in rows where column B is ‘X’. The following formula doesn’t work (using “Max” as the example person to search for).

Can you advise on what will do this elegantly?

```
=COUNTIFS(C5:L100,"Max",B5:B100,"X")
```

I think an array formula might be in order, but I’m not too experienced on those.

```
=SUMPRODUCT((C5:L100="Max")*(B5:B100="X"))
```

### Answer：

One way to do this is to just do it column by column:

```
=COUNTIFS(C5:C100,"Max",B5:B100,"X")+COUNTIFS(D5:D100,"Max",B5:B100,"X")... etc
```

Does the trick, but not too elegant if you have loads of columns to look through. I’m sure there’s a tidier way using an array formula.

Tags: excelexcel