版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
版权
VBA专栏收录该内容
39 篇文章4 订阅
订阅专栏
Sub 分类() Dim A Dim cnn, SQL$ Set cnn = CreateObject("adodb.connection") Set RS = CreateObject("adodb.recordset") cnn.Open "Provider = Microsoft.ace.Oledb.12.0;Extended Properties =TEXT;Data Source =" & ThisWorkbook.Path & "\" A = "(SELECT EUTRANCELLTDD,MAX(pmRrcConnMax) AS pmRrcConnMax FROM [TDD.CSV] GROUP BY EUTRANCELLTDD)" SQL = "SELECT A.* FROM [TDD.CSV] A, " & A & " B where a.eutrancelltdd=b.eutrancelltdd and a.pmRrcConnMax=b.pmRrcConnMax" Set RS = cnn.Execute(SQL) Sheets("结果").Cells.ClearContents Sheets("结果").Range("a2").CopyFromRecordset RS For i = 0 To RS.Fields.Count - 1 Sheets("结果").Cells(1, i + 1) = RS.Fields(i).Name Next Worksheets("结果").Activate MsgBox ("OK") End Sub