やってみました。できるようです。
なお、やってみる限り、
シート上のリストをテーブルに見立てる場合は
table1にtable2をLeftJoin
table1にtable3をLeftJoin
はできず、
table1にtable2をLeftJoin
Joinしたテーブルにtable3をLeftJoin
とする必要があるようです。
Sub Test1()
Dim cn As Object
Dim rs As Object
Dim wkSQL As String
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Provider = "Microsoft.ACE.OLEDB.12.0"
cn.Properties("Extended Properties") = "Excel 12.0;HDR=YES;IMEX=1"
cn.Open ThisWorkbook.FullName
With ThisWorkbook.Sheets("Sh4")
wkSQL = ""
wkSQL = wkSQL & "SELECT T1.[品番],T1.[規格],T1.[個数],[サイズ],T3.[好み]" & vbCrLf
wkSQL = wkSQL & "FROM ([Sh1$A1:G65000] as T1" & vbCrLf
wkSQL = wkSQL & "Left Join [Sh2$A1:G65000] as T2 " & vbCrLf
wkSQL = wkSQL & " ON T1.[品番] = T2.[品番] and T1.[規格] = T2.[規格])" & vbCrLf
wkSQL = wkSQL & "Left Join [Sh3$A1:G65000] as T3 " & vbCrLf
wkSQL = wkSQL & " ON T1.[品番] = T3.[品番] and T1.[規格] = T3.[規格]" & vbCrLf
rs.Open wkSQL, cn
.Cells(2, 1).CopyFromRecordset rs '結果セットを格納
End With
rs.Close '以下後処理
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub