Query SQL from Excel

rrdavis07

New Member
Joined
Apr 25, 2012
Messages
4
I'm attempting to create a MS Query to return data from a SQL database based on a value from a cell in Excel. I have actually successful accomplished this, but only for 1 row. I cant figure out how to get it to copy-down to other rows.


I've created a connection as follows:

2016-12-05_12-08-30.jpg



Notice that the SQL statement includes a parameter. The parameter is set to point to a specific cell:
2016-12-05_12-14-13.jpg



I guess this makes sense as I'm only looking to return 1 value per row:The problem is that I have multiple lines to return values for. How do I return a value per row for multiple rows?
2016-12-05_12-22-33.jpg



I've tried changing the cell reference in the Parameters dialog box (image #2 above), but this does not work as the Excel Table is designed to grow dynamically. Is it possible to have Query several values based on different rows within Excel?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

rrdavis07

New Member
Joined
Apr 25, 2012
Messages
4
Apparently, I'm not able to include screenshots. Are images actually supposed to show? In the Testing area, the link appeared but not the picture. Here, there is just an icon.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,957
Office Version
  1. 365
Platform
  1. Windows
There are tools you can use to post screen images. They are listed in Section B of this link here: Guidelines for Forum Use.

Also, there is a Test Here forum on this board that you can use to test out these tools to make sure they are working correctly before using them in your question.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,783
Messages
5,638,301
Members
417,020
Latest member
MSVII

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
Top