Sub 雷パッドの売上を読み込む()
    Dim filePath As String
    Dim mCode As Variant
    Dim formulaText As String
    Dim ws As Worksheet
    Dim lo As ListObject

    filePath = ThisWorkbook.Path & "\1月営業成績.xlsx"

    mCode = Array( _
        "let", _
        "    ソース = Excel.Workbook(File.Contents(""" & filePath & """), null, true),", _
        "    対象テーブル = ソース{[Item=""T_1月営業成績"", Kind=""Table""]}[Data],", _
        "    抽出された行 = Table.SelectRows(", _
        "        対象テーブル,", _
        "        each [商品名] = ""雷パッド""", _
        "    )", _
        "in", _
        "    抽出された行" _
    )

    formulaText = Join(mCode, vbCrLf)

    ThisWorkbook.Queries.Add _
        Name:="雷パッドの売上", _
        Formula:=formulaText

    Set ws = ThisWorkbook.Worksheets("出力")

    Set lo = ws.ListObjects.Add( _
        SourceType:=0, _
        Source:= _
            "OLEDB;Provider=Microsoft.Mashup.OleDb.1;" & _
            "Data Source=$Workbook$;" & _
            "Location=""雷パッドの売上"";", _
        Destination:=ws.Range("A1") _
    )

    With lo
        .Name = "T_雷パッドの売上"

        With .QueryTable
            .CommandType = xlCmdSql
            .CommandText = Array("SELECT * FROM [雷パッドの売上]")
            .Refresh BackgroundQuery:=False
        End With
    End With

    ThisWorkbook.Queries("雷パッドの売上").Delete
End Sub
