In some situations, you may need to count unique records in a range. The below figure shows an example. Column A has a list of cities, and the goal is to count the number of unique cities in the list. The formula in cell C3 returns 7, which is the number of unique cities.
To get the result we need to use Array Formula. This formula is: =SUM(1/COUNTIF(A1:A10,A1:A10))
Press Ctrl+Shift+Enter after writing the formula to get the desired output.