View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel[_2_] Nigel[_2_] is offline
external usenet poster
 
Posts: 735
Default VBA Excel 2007 SQL query

Turn on the macro recorder, then tab to DATA and set up your connection
'From other sources', and query options. Turn off recorder and you will have
a skeleton code that you can adapt for general use.

--

Regards,
Nigel




"Striker" wrote in message
...
I'm trying to query a SQL database and bring the results to a spreadsheet.
Be gentle on my, I have not coded in VBA for many years.

I'm thinking I can open a connection lke this
Set MyConnection = new ADODB.connectio0n
MyConnection.Open "Driver=SQL
Server;Server=MyServerName;Database=MyDatabase; (not sure I need a
password)

So question is how do I run a SQL query? I have only used this to add
stuff to a database before?