Skip to content
Advertisement

Excel 2003 send date parameters to SQL query

I have a few worksheets that use sql queries to retrieve data. I would like all of these sheets to query data based on the same date range entered by a user in excel.

eg. I would enter somewhere in a form or in a cell a date range and retrieve the value in sql to obtain data based on the user specified dates.

Is there anyway to access values from forms or from cells in SQL (Query editor perhaps)?

Advertisement

Answer

In MS Query (which you use to build a QueryTable) set the tick to display the Criteria grid, and for required fields enter something in brackets as a criterion value:
A screenshot http://img228.imageshack.us/img228/4593/97662427.gif

This will create two parameters in the query. Save and return to Excel, right-click the QueryTable, click Parameters... and point them to the right cells.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement