Yes, this can be done using the COUNTIF function with a condition based on a lookup in a list of values. Here are the steps to follow:
- Select a cell where you want to display the result of the COUNTIF function.
- Type the following formula in the formula bar:
Code:
=COUNTIF(PRIMARY_COLORS,A1)+COUNTIF(PRIMARY_COLORS,B1)+COUNTIF(PRIMARY_COLORS,C1)+COUNTIF(PRIMARY_COLORS,D1)
Note: A1, B1, C1, and D1 are the cells that contain the input data.
- Press Enter to apply the formula.
The formula will count the number of times the values in the input data row match any of the values in the PRIMARY_COLORS range.
Alternatively, you can use the SUMPRODUCT function to achieve the same result with a single formula. Here's how:
- Select a cell where you want to display the result of the formula.
- Type the following formula in the formula bar:
Code:
=SUMPRODUCT(COUNTIF(PRIMARY_COLORS,A1:D1))
Note: A1:D1 are the cells that contain the input data.
- Press Enter to apply the formula.
The formula will count the number of times the values in the input data row match any of the values in the PRIMARY_COLORS range.