|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 limonet 于 2023-1-4 16:04 编辑
Sub limonet()
Dim Cn As Object, StrSQL$, FileName As Variant
Set Cn = CreateObject("adodb.connection")
FileName = Application.GetOpenFilename(filefilter:="Excel工作簿文件,*.xls?", MultiSelect:=true)
If TypeName(FileName) = "Boolean" Then Exit Sub
Cn.Open "provider=microsoft.ace.oledb.12.0;extended properties=excel 12.0;data source=" & FileName
StrSQL = "select 商品名称Xin,商品规格Xin,生产企业Xin,批准文号Xin from [Sheet1$A2:H]a right JOIN [excel 12.0;database=" _
& ThisWorkbook.FullName & "].[Sheet1$F3:j]b on b.商品编号NEW=a.商品编号Xin"
Range("G4").CopyFromRecordset Cn.Execute(StrSQL)
End Sub |
|