» Add unique values using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Custom Functions , Printing in VBA
VERSION - All Microsoft Excel Versions
Function SumUniqueValues(InputRange As Range) as Double
Dim cl As Range, UniqueValues As New Collection, uValue As Variant
Application.Volatile
On Error Resume Next
For Each cl In InputRange
UniqueValues.Add cl.Value, CStr(cl.Value)
Next cl
On Error GoTo 0
SumUniqueValues = 0
For Each uValue In UniqueValues
SumUniqueValues = SumUniqueValues + uValue
Next uValue
End Function
Example:
=SumUniqueValues(A1:A100) will add the unique values in the range A1:A100.
Book Store:
Recommended Books:
- Dictionary of Finance and Investment Terms
- Successful Business Planning in 30 Days: A Step-By-Step Guide for Writing a Business Plan and Starting Your Own Business
- Financial Statement Analysis with S&P insert card
- Harry Potter and the Order of the Phoenix (Book 5)
- The McGraw-Hill Guide to Writing a High-Impact Business Plan: A Proven Blueprint for First-Time Entrepreneurs
- Real Estate Finance and Investments (Real Estate Finance and Investments, 11th Ed)
No comments have been submitted.

