How to embed a query within an Excel range so the rows grow or decrease along with the query results
Posted on 2015-01-19
I have been messing with this problem for a few weeks and cannot seem to get it to work.
I have a workbook that reflects metrics for physicians in 5 different sections. The first two sections have static rows and the data is retrieved using SUMIFS formulas and a tab of information from an MS-Query to a SQL db.
The other 3 are what is giving me heartburn.
I have to track the # of Inpatient, Outpatient and Surgeries Admitted by a specific physician, reflecting the Attending Physician totals for a specified period of time.
I can easily create a SQL query and a stored procedure in the main database to obtain the summary information I want. My biggest problem is that the users are not given the privilege to run a stored procedure.
Is there a way to bring in a master table from SQL. Summarize the data in the manner I need for the physician chosen and embed the data into the correct area of the workbook. The row count will fluctuate depending on the number of attending physicians in the time frame. So the different section lengths will fluctuate.
The format would look something like this:
Admitting Physician XYZ
Attending Physician A 10
Attending Physician B 4
Attending Physician C 3
Total for XYZ 17