Dynamically create worksheets & queries based on date

amorts

Board Regular
Joined
Jan 4, 2006
Messages
181
Hi Guys,

I am working on a report which is to be called from a DTS package in SQL Server 2000 and populated with data.

A stored proc is called which populates data for each year (1st Oct - 30th Sep) - 2 tables hold the information for each year. Each of these tables represents a worksheet on my template.

The query is a simple select statement and dump into the worksheet for each tab and each worksheet follows the same format.

Based upon the date the template is called I need to be able to carry out the following;
1. Add and name the correct number of worksheets
2. Dynamically construct the SQL query to query the correct table and place the recordset on the correct worksheet.

As all the tables follow the same naming conventions my first thoughts were to run these table names into an array within excel - after this I am at a loss!!

Thanks all!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,214,985
Messages
6,122,602
Members
449,089
Latest member
Motoracer88

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