# How to Calculate Sample Size in Excel (With Example)

You can use the COUNTA function to calculate the sample size of a dataset in Excel.

This function uses the following basic syntax:

```=COUNTA(A2:A16)
```

This particular formula counts all of the non-blank cells in the range A2:A16.

The following example shows how to use this function to calculate a sample size in Excel in practice.

## Example: Calculating Sample Size in Excel

Suppose we have the following dataset that shows the points scored by basketball players on various teams: We can type the following formula into cell E1 to calculate the sample size of this dataset:

`=COUNTA(A2:A16)`

The following screenshot shows how to use this formula in practice: From the output we can see that the sample size is 15.

Note that if we’d like to calculate the sample size using a criteria, we could use the COUNTIF function instead.

For example, we could use the following formula to calculate the sample size only for the players on the Hawks team:

`=COUNTIF(A2:A16, "Hawks")`

The following screenshot shows how to use this formula in practice: From the output we can see that the sample size for the players on the Hawks team is 5.

We could also use the <> symbols to calculate the sample size for the players who are not on the Hawks team:

`=COUNTIF(A2:A16, "<>Hawks")`

The following screenshot shows how to use this formula in practice: From the output we can see that the sample size for the players not on the Hawks team is 10.