|
- Sub 双薄首表相同记录ado参考()
- Dim cnn As Object, SQL$, sh As Worksheet
- Set cnn = CreateObject("ADODB.Connection")
- cnn.Open "Provider=Microsoft.Ace.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & ThisWorkbook.Path & "\表1.xlsx"
- SQL = "SELECT a.小区名称,a.开始时间,b.开始时间,a.RRC连接建立成功率,b.RRC连接建立成功率,a.RRC连接建立成功率-b.RRC连接建立成功率 FROM [表1$] a, [Excel 12.0;Database=" & ThisWorkbook.Path & "\表2.xlsx;].[表2$] b where a.小区名称=b.小区名称 "
- On Error Resume Next
- Set sh = Sheets("相同记录")
- If Not sh Is Nothing Then
- sh.Cells.Clear
- Else
- Sheets.Add.Name = "相同记录"
- End If
- Sheets("相同记录").Range("A2").CopyFromRecordset cnn.Execute(SQL)
- cnn.Close
- Set cnn = Nothing
- End Sub
复制代码 |
|