Reputation: 37
I'm doing excel data verification and would like to view any discrepancies within each column. And I think executing
"select distinct column1 from table_name"
is efficient. Is there a way to do that in vba with/without connecting to any database? Any advice would be appreciated.
Upvotes: 0
Views: 293
Reputation: 1816
This code should do the SELECT DISTINCT for one column:
ActiveSheet.Range("A2:A65536").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ActiveSheet.Range("B2"), Unique:=True
The code will paste the Distinct values from activesheet column A to column B. Hope this helps
Upvotes: 1