How to retrieve data from Excel with ADODB connection if the first line of the worksheet does not have the column name?

后端 未结 3 1083
野趣味
野趣味 2020-12-19 16:02

I use the following type of code to retrieve data from some Excel Workbooks (path is a Parameter)

Dim strSQL  As String, conStr as String
Dim cnn As New ADOD         


        
3条回答
  •  情深已故
    2020-12-19 16:24

    Use a named or unnamed range in your query:

    strQuery = "SELECT * FROM MyRange"
    
    strQuery = "SELECT * FROM [Sheet1$A1:B10]"
    

    See these Microsoft support articles for more information:

    How To Use ADO with Excel Data from Visual Basic or VBA

    ExcelADO demonstrates how to use ADO to read and write data in Excel workbooks

提交回复
热议问题