• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Using excel data for parameters in a sql script

mr_hiboy

Member
Hey,


I was wonder if it is possible to have a macro retrieve data from a sql database using some parameters in a workbook, basic example.


Cell A1 has customerID, if I enter 123 and run a macro can it select customer 123 from a database to show name is cell B1


Thanks

Paul
 
Certainly. When you setup the SQL query, you can define some of the criteria to be Parameters. See here:

http://office.microsoft.com/en-us/excel-help/customize-a-parameter-query-HP010216113.aspx?pid=CH100648471033


Then, in your macro, you could just arrange for the correct data to be placed in the parameter cell before running the query.
 
Hi, mr_hiboy!

Adding my two cents to the helpful link posted by Luke M, if you find any issue consider posting the macro with the SQL string build & connection so as to try to fix in the rude way, i.e., changing the query definition string.

Regards!
 
Back
Top