I have this code which opens the Excel file and gets the "Sql" string just fine.
I want to then write some data back out to another TAB on the same eeXcel file using the SQLInsert string below.
I am getting an error "Syntax error in INSERT INTO Statement".
here is what the line has created, it has a name and some counts accumulated as it moves in a loop.
Insert into ([Sheet1$]) Select ([Flintstone, Fred (14, 0, 6)]) as Expr1
What do I need to do to make the Insert statement correct?
TIA
I want to then write some data back out to another TAB on the same eeXcel file using the SQLInsert string below.
I am getting an error "Syntax error in INSERT INTO Statement".
here is what the line has created, it has a name and some counts accumulated as it moves in a loop.
Insert into ([Sheet1$]) Select ([Flintstone, Fred (14, 0, 6)]) as Expr1
What do I need to do to make the Insert statement correct?
TIA
Code:
Path = "C:\"
Filename = "myfile.xls"
Set cn = New ADODB.Connection
Set rsT = New ADODB.Recordset
Set rsT4 = New ADODB.Recordset
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & Path & _
"\" & Filename & ";Extended Properties=Excel 8.0;"
.CursorLocation = adUseClient
.Open
End With
Sql = "Select[LDAP Manager], Count([LDAP Full Name]) as Total from [Base$] " & _
"Group by [LDAP Manager]"
rsT.Open Sql, cn, adOpenDynamic, adLockPessimistic
....
SQLInsert = "Insert into ([Sheet1$]) Select ([" & CountData & "]) as Expr1"
rsT4.Open SQLInsert, cn, adOpenDynamic, adLockPessimistic
rsT4.Close
DougP