Excel VBA Get unique values in one column in an Excel table


I have a table in Excel that was pulled in from SharePoint
What VBA code would I use to find the unique values in one column
as you would see if you clicked on the dropdown arrow in
the header cell?

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ProfessorJimJamMicrosoft Excel ExpertCommented:
you do not need VBA to find unique values.  use conditional formatting .

select the data then follow the navigation shown in image attached.

Rory ArchibaldCommented:
Generic function to return a unique list from a range:

Public Function UniqueList(rngInput As Range) As Variant
   Dim rngCell           As Range
   Dim dic           As Object
   Dim lngRow            As Long

   Set dic = CreateObject("Scripting.Dictionary")
   For Each rngCell In rngInput.Cells
      If Len(rngCell.Value) <> 0 Then dic(CStr(rngCell.Value)) = Empty
    Next rngCell
   UniqueList = dic.Keys
End Function

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You can used the AdvancedFilter feature, either in the Excel GUI or in VBA code, to populate a range with the unique values, or filter the list in-place.
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thank you to those who avoided VBA, but I specifically asked for VBA as this is part of an automated application
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.