Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Template
Hello
I have a business type spreadsheet which I open up new every week. It is saved as a template. When I open a new week I would like to import some data from the previous week i.e. previous week last day sales. I would also like to add the dates and days for the current week as well. Is there any way I can add this information without having to set up 12 months in advance Thanks Steve |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Template
write a macro that runs when you create a new sheet, have the macro open
your previous week and get the data. Example code (to be added to the thisworkbook code): Option Explicit Private Sub Workbook_Open() Dim Filename As String Dim PreviousWorkbook As Workbook ' Newly created from template? if path is empty then it is new If ActiveWorkbook.Path = "" Then ' New workbook is being created from template ' ask for filename to get data from Filename = Application.GetOpenFilename("Workbook (*.xls), *.xls", , "Where to get last weeks data?") ' Open old workbook read-only PreviousWorkbook = Application.Workbooks.Open(Filename, , True) ' Copy data ' Now here add your code to copy the data from your old workbook to your new one ' Done copying, so close the old workbook, don't save changes PreviousWorkbook.Close savechanges:=False PreviousWorkbook = Nothing ' let user know we're finished MsgBox "Your new workbook is ready to use!" Else ' do nothing, existing workbook is being opened End If End Sub "wally" wrote in message ... Hello I have a business type spreadsheet which I open up new every week. It is saved as a template. When I open a new week I would like to import some data from the previous week i.e. previous week last day sales. I would also like to add the dates and days for the current week as well. Is there any way I can add this information without having to set up 12 months in advance Thanks Steve |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Template
write a macro that runs when you create a new sheet, have the macro open
your previous week and get the data. Example code (to be added to the thisworkbook code): Option Explicit Private Sub Workbook_Open() Dim Filename As String Dim PreviousWorkbook As Workbook ' Newly created from template? if path is empty then it is new If ActiveWorkbook.Path = "" Then ' New workbook is being created from template ' ask for filename to get data from Filename = Application.GetOpenFilename("Workbook (*.xls), *.xls", , "Where to get last weeks data?") ' Open old workbook read-only PreviousWorkbook = Application.Workbooks.Open(Filename, , True) ' Copy data ' Now here add your code to copy the data from your old workbook to your new one ' Done copying, so close the old workbook, don't save changes PreviousWorkbook.Close savechanges:=False PreviousWorkbook = Nothing ' let user know we're finished MsgBox "Your new workbook is ready to use!" Else ' do nothing, existing workbook is being opened End If End Sub "wally" wrote in message ... Hello I have a business type spreadsheet which I open up new every week. It is saved as a template. When I open a new week I would like to import some data from the previous week i.e. previous week last day sales. I would also like to add the dates and days for the current week as well. Is there any way I can add this information without having to set up 12 months in advance Thanks Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I link between a Word template and an Excel template | Excel Discussion (Misc queries) | |||
Automatically look in template folder when one opens a template | Excel Discussion (Misc queries) | |||
How do I distribute a template created with Template Wizard ? | Excel Discussion (Misc queries) | |||
NCAA tournament brackets template from Template gallery. | Excel Worksheet Functions | |||
Excel template to load automatically as the default template? | Excel Discussion (Misc queries) |