|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 limonet 于 2023-7-2 21:02 编辑
Sub limonet()
Dim Cn As Object, StrSQL$
Set Cn = CreateObject("adodb.connection")
Cn.Open "provider=microsoft.ace.oledb.12.0;extended properties=excel 12.0;data source=" & ThisWorkbook.FullName
Sheet2.Range("B3").CopyFromRecordset Cn.Execute("select 姓名,count(*) from [源数据表$] group by 姓名 having count(*)>=2")
Sheet3.Range("B4").CopyFromRecordset Cn.Execute("select * from(select 姓名,first(证号) as 证号,count(*) from [源数据表$] group by 姓名 having count(*)=1) order by 证号")
End Sub
|
|