|
或使用instr函数:
- Sub ADO法2()
- Dim cnn As Object, SQL$
- Set cnn = CreateObject("ADODB.Connection")
- cnn.Open "provider=Microsoft.ACE.OLEDB.12.0;extended properties='excel 12.0;hdr=no';data source=" & ThisWorkbook.Path & "\456.xlsx"
- SQL = "select iif(isnull(b.f1),'没有找到',b.f1),f2,f3 from [Excel 12.0;hdr=no;Database=" & ThisWorkbook.FullName & "].[Sheet1$A2:A" & Cells(Rows.Count, 1).End(xlUp).Row & "] a left join [Sheet1$] b on instr(b.f3 ,a.f1)>0"
- [c2].CopyFromRecordset cnn.Execute(SQL)
- cnn.Close
- Set cnn = Nothing
- End Sub
复制代码
Desktop.rar
(25.87 KB, 下载次数: 20)
|
|