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

[µo°Ý] ¶µ¬Û¤ÀÃþ­«¾ã

¦^´_ 12# mdr0465


    ·PÁ­ɦ¹ÃD½m²ß ªþ¤WÀÉ®×

Sub ¤ÀÃþ()
With CreateObject("adodb.connection"): V = Application.Version:
If V >= 12 Then V = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0; "
If V < 12 Then V = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0; "
.Open V & "Data Source=" & ThisWorkbook.FullName
Set s = Sheets("µ²ªG"): Set s1 = Sheets("¤ÀÃþ±b")
ar = s1.Range("b1:H1")
tx = Join(Application.Index(ar, 1, 0), ",")
Set rs = .Execute("select distinct " & s1.[A1] & " from [¤ÀÃþ±b$A1:A]")
rr = rs.getrows(, , "©ú²Ó¬ì¥Ø_¹ô§O")
s.Cells.ClearContents
For Each Z In rr
r = s.Cells(Rows.Count, 1).End(3).Row + 2
s.Cells(r, 1) = Z
s.Cells(r + 1, 1).Resize(1, UBound(ar, 2)) = ar
q = "select " & tx & " from [¤ÀÃþ±b$A1:H] where ©ú²Ó¬ì¥Ø_¹ô§O = '" & Z & "' and ºK­n not like '%¥»%¤é%¦X%­p%' and ºK­n not like '%¥»%¦~%²Ö%­p%'"
s.Cells(r + 2, 1).CopyFromRecordset .Execute(q)
Next
s.Rows("1:2").Delete Shift:=xlUp
r = s.Cells(Rows.Count, 1).End(3).Row
s.Cells(1, 1).Resize(r, 7).Borders.LineStyle = 1
End With
End Sub

¤ÀÃþ±b.zip (176.6 KB)

TOP

¦^´_ 14# Andy2483


    ¬Oªº
¥Îvba ½Õ¥Îsql¨Ó³B²zexcel¬Y¨Ç¸ê®Æ¾ã²zªº°ÝÃD

TOP

        ÀR«ä¦Û¦b : ¦Û¤v®`¦Û¤v¡A²ö¹L©ó¶ÃµoµÊ®ð¡C
ªð¦^¦Cªí ¤W¤@¥DÃD