The first problem is how to determine whole numbers.

This can be done with theINT,TRUNC, or MOD functionsas explained in detail here.

You might at first be tempted to use theCOUNTIForCOUNTIFSfunctions.

Excel formula: Number is whole number

Instead, we need a way to work with the array directly withBoolean logic.

Next, we need to convert the TRUE and FALSE values to 1s and 0s.

The formula in G6:

Note the only change to the formula is the logical operator.

Excel formula: Highlight integers only

This time instead of multiplying the Boolean array byshares, we multiply byvalue.

SUM or SUMPRODUCT?

Why are we using SUMPRODUCT and not theSUM function?

Excel formula: Get integer part of a number

It’s a good question.

In Excel 365, SUM willjust work, sinceExcel 365 handles arrays natively.

For more details, seeWhy SUMPRODUCT?

Excel formula: Extract date from a date and time

For example, MOD(10,3) = 1.

The result of MOD carries the same sign as the divisor.

SUMPRODUCT Function

The Excel SUMPRODUCT function multipliesrangesorarraystogether and returns the sum of products.

Excel MOD function

Excel SUMPRODUCT function