- Put square brackets around
position
(seems to be a reserved word). - Remove the
IMEX=1
from the connection string, or you get an error "operation must use an updateable query"
Revised code:
Sub Tester()
update "update [Regional Personnel$] set name='Ada Lovelace'," & _
" [Phone]='(303) 555-1337', [lan id]='ADL3', [position]='Engineer' where id=3"
End Sub
Sub update(sql As String)
Dim objconnection As New ADODB.Connection
objconnection.CommandTimeout = 99999999
objconnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.FullName & ";" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES;"";"
objconnection.Execute sql
End Sub