0

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.

bananaLeaf
  • 37
  • 1
  • 6

1 Answers1

1

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

neophyte
  • 1,726
  • 3
  • 15
  • 21