Code: Select all
MyQuery = "INSERT INTO FC_VALUES (ITEM_NUMBER,ITEM_DESC) VALUES ('EXCELTESTNUMBER','TEST DESCRIPTION')"
'MsgBox MyQuery
Sheets("Sheet1").Select
Range("A1").Select
Sqlstring = MyQuery '"select IDCUST from ARCUS"
connstring = "ODBC;DSN=ODBCTEST;UID=sa;PWD=password01#;Database=FC_DB"
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=Sqlstring)
.Refresh
End With
If i had to run the query twice its shifts A1 to A2 and put some text into A1 "Excel Query" or something like that.
I want to run a SQL query without it putting text on the sheet.
How can i do that?
I even tried to put the code in Sheet1 then Say Sheet2.A1