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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,851
Members
449,051
Latest member
excelquestion515

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