|
Option Explicit
Sub A()
Dim cnn, rs As Object, Sql As String, arr, i%, s$, j%, m%, t%, brr, bt
Dim TM
TM = Timer
Set bt = Sheet1.[a1:S1]
Set cnn = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.Recordset")
cnn.Open "Provider=Microsoft.ACE.OleDb.12.0;Extended Properties='Excel 12.0;HDR=YES'; Data Source=" & ThisWorkbook.FullName
Sql = "select distinct CJQYMC from [标注$A1:a] where CJQYMC is not null "
arr = cnn.Execute(Sql).getrows
Sql = "select CJQYMC,count(*) from [标注$A1:a] where CJQYMC is not null group by CJQYMC order by 2 desc"
brr = cnn.Execute(Sql).getrows
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For t = 1 To Int(brr(1, 0) / 25 + 0.99)
j = j + 1
Workbooks.Add
bt.Copy [a1]
For i = 0 To UBound(arr, 2)
Sql = "select * from [标注$A1:s] where CJQYMC='" & arr(0, i) & " '"
rs.Open Sql, cnn, 1, 1
rs.Move (j - 1) * 25
m = [a9999].End(3).Row
Range("a1").Offset(m, 0).CopyFromRecordset rs, 25
rs.Close
Next
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\分类后\" & (j - 1) * 25 + 1 & "-" & (j - 1) * 25 + 25 & ".xls", -4143
ActiveWorkbook.Close 1
Next
cnn.Close
Set rs = Nothing
Set cnn = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "OK" & vbLf & Format(Timer - TM, "0.00秒")
End Sub
|
评分
-
1
查看全部评分
-
|