Using an array or dictionary as from clause in sql in excel vba

后端 未结 3 1930
醉梦人生
醉梦人生 2021-01-21 19:35

Is it possible to use an array or dictionary as the table in a SQL statement.

e.g. strSQL = \"SELECT * FROM \" & myArray & \"\"

Thanks in advance.

3条回答
  •  离开以前
    2021-01-21 20:07

    Dim a(3) As Variant
    
    a(0) = 1
    a(1) = 2
    a(2) = 3
    a(3) = 4
    
    Debug.Print "select * from xyz where id in (" & Join(a, ",") & ")"
    

提交回复
热议问题