Use VBA to generate SQL reports

Stephanie30

New Member
Joined
May 21, 2015
Messages
13
Hi

I need help in writing a vba code which would connect to SQL and run a SQL statement to generate a report based on company name. The code should then save the output to the defined location in the excel data table

The data table in excel has company names from b2:b50. Column C is a user field where a user will mention as YES if they need the report for that company.

The user will also mention in column D whether which location they would want to save the report output

Once when the above is updated, the user will trigger the macro and the code should connect to SQL database and extract Reports based on the company name mentioned in column B
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
There is absolutely nothing to go on there! Perhaps you could start with the database connection... What is it called? Where is it located? What is the name of the Table the records are on? Which records do you want to import? Import all fields from each record or just a couple? etc etc
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top