Excel SQL - 列/范围单元格中的值

时间:2017-06-22 12:14:43

标签: sql excel vba ms-office

我试图从表data中检索A列(单元格A1到A20000)中的数据。当我提出此查询时,我收到错误:"意外的额外令牌Dim"。我做错了什么?

SELECT 
    OZATI_etc.Account, 
    OZATI_etc.Equipment
FROM 
    OZATI_etc
WHERE 
    OZATI_etc.Account IN (SELECT * FROM [data$A1:A20000])
ORDER BY
    OZATI_etc.Account

    Dim currentRow As Integer
    Dim str As String
    currentRow = 1
    Do While (sheets("data").Range("A" & currentRow).Value <> "")
        str = str & ",'" & sheets("data").Range("A" & currentRow).Value & "'"
        currentRow = currentRow + 1
    Loop
    str = Mid(str, 2)

0 个答案:

没有答案