Unique Count (Excel VBA vs Formulas) Faster Approach
问题 32 Bit Excel 365 on 64 Bit Win7 Worksheet 300600 Rows x 105 Columns Goal: Calculate the Number of Unique Entries in each Column Attempted Solution 1: Formula {=SUM(1/COUNTIF(A8:A300600,A8:A300600))} Issue: Long Runtime, Freezes Excel, Must Stop Calculation Attempted Solution 2: VBA UDF Function UniqueCount(Selection As Range) As Integer Dim UniqueArray() ReDim UniqueArray(0 To Selection.Count) Dim Rng As Range Dim CUniqueCount As Integer CUniqueCount = 0 For Each Rng In Selection For i = 0 To