简体   繁体   中英

execute sql query on excel columns using vba

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM