ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] «O¯d¨S¦³­«½ÆªºÄæ¦ì

¦^´_ 1# ssooi


¨âºØ¼gªk   ¦Û¤v¬D¤@­Ó
Sub t1()
o = Split("Provider=Microsoft.,,.0;Extended Properties=Excel ,,.0;Data Source=" & ThisWorkbook.FullName, ",")
Set cn = CreateObject("adodb.connection"): If Application.Version > 12 Then o(1) = "ACE.OLEDB.12": _
o(3) = 12: cn.Open Join(o, "") Else o(1) = "Jet.OLEDB.4": o(3) = 8: cn.Open Join(o, "")
    q = "SELECT a.§Ç¸¹, a.®Éµ{, a.µP¤l FROM [¤u§@ªí2$A1:C] as a "
q = q & "WHERE EXISTS ( SELECT 1 FROM [¤u§@ªí2$A1:C] AS b "
q = q & "               WHERE b.§Ç¸¹ = a.§Ç¸¹ AND b.µP¤l = a.µP¤l "
q = q & "               GROUP BY b.§Ç¸¹, b.µP¤l HAVING COUNT(*) = 1)"
[G:J].ClearContents: [G1].CopyFromRecordset cn.Execute(q)
End Sub




Sub t2()
o = Split("Provider=Microsoft.,,.0;Extended Properties=Excel ,,.0;Data Source=" & ThisWorkbook.FullName, ",")
Set cn = CreateObject("adodb.connection"): If Application.Version > 12 Then o(1) = "ACE.OLEDB.12": _
o(3) = 12: cn.Open Join(o, "") Else o(1) = "Jet.OLEDB.4": o(3) = 8: cn.Open Join(o, "")
    q = "SELECT a.§Ç¸¹, a.®Éµ{, a.µP¤l FROM [¤u§@ªí2$A1:C] AS a "
q = q & "WHERE ( SELECT COUNT(*) FROM [¤u§@ªí2$A1:C] AS b "
q = q & "        WHERE b.§Ç¸¹ = a.§Ç¸¹ AND b.µP¤l = a.µP¤l) = 1"
[G:J].ClearContents: [G1].CopyFromRecordset cn.Execute(q)
End Sub

TEST.zip (15.54 KB)

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-12-2 07:56 ½s¿è

¦^´_ 19# singo1232001



   Sub t5()
I = Split("Provider=Microsoft.,Jet.OLEDB.4,.0;Extended Properties=Excel ,8,.0;Data Source=", ",")
If Application.Version > 12 Then I(1) = "ACE.OLEDB.12": I(3) = 12
Set cn = CreateObject("adodb.connection"): cn.Open Join(I, "") & ThisWorkbook.FullName
   q = "SELECT a.§Ç¸¹, a.®Éµ{, a.µP¤l FROM [¤u§@ªí2$A1:C] AS a WHERE (  SELECT COUNT(*) "
q = q & "FROM [¤u§@ªí2$A1:C] AS b WHERE b.§Ç¸¹ = a.§Ç¸¹ AND b.µP¤l = a.µP¤l) = 1"
[G:J].ClearContents: [G1].CopyFromRecordset cn.Execute(q)
End Sub

§Úı±o «e¤T¦æªº¤è¦¡ À³¸Ó¬Oadodb.connection ©I¥s³Ì²µuªº¤@ºØ¼gªk¤F

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¤H¤£©È¿ù¡A´N©È¤£§ï¹L¡A§ï¹L¨Ã¤£Ãø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD