Below is the excel table i want to manipulate via SQL query in VBA.
Sub SQL()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
strFile = ThisWorkbook.FullName
strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFile _
& ";Extended Properties=""Excel 12.0;HDR=Yes;IMEX=1"";"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open strCon
strSQL = "SELECT [Sr] FROM [Table1$] WHERE [Sr] >= 3 AND [Sr] <= 8;"
rs.Open strSQL, cn
Sheet5.Range("D1").CopyFromRecordset rs
End Sub
I am getting below error for my above code.
Please guide how can i manipulate excel table in SQL query in VBA.