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:




Notice that the SQL statement includes a parameter. The parameter is set to point to a specific cell:



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?



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?
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

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
53,410
Office Version
365
Platform
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,099,026
Messages
5,466,113
Members
406,466
Latest member
mimi_b

This Week's Hot Topics

Top