#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 12
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I link between a Word template and an Excel template Josh Excel Discussion (Misc queries) 0 April 1st 08 12:36 AM
Automatically look in template folder when one opens a template hmm Excel Discussion (Misc queries) 0 July 11th 07 04:26 PM
How do I distribute a template created with Template Wizard ? Sofia Excel Discussion (Misc queries) 0 June 20th 07 04:51 PM
NCAA tournament brackets template from Template gallery. smcclements Excel Worksheet Functions 2 March 16th 07 02:33 PM
Excel template to load automatically as the default template? David Excel Discussion (Misc queries) 1 March 21st 05 12:24 PM


All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"