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!
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Watch MrExcel Video

Forum statistics

Threads
1,123,318
Messages
5,600,924
Members
414,416
Latest member
Nobu

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
Top