Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Made some final tweaks and this is the outcome of the final product.
Sub CreateReports() Dim CCRange As Range Dim fname As Variant Dim bname As Variant ' Disable screenupdating to increase speed and minimise use of ' system memory Application.ScreenUpdating = False ' make sure that excel does not calculate automatically Application.Calculation = xlCalculationManual ' do not display any alerts - such as (overwrite existing file) Application.DisplayAlerts = False ' location of where the reports will be saved MyPath = "C:\TEMPTRIAL\REPORTS\" ' Change directory path to the location above ChDir MyPath ' inititate loop in range For Each c In Range("loop.range") ' Open budget template workbook Workbooks.Add Template:="C:\TEMPTRIAL\budget worksheet template.XLT" ' return to 2008/09 Master Worksheet Windows("2008-09 Budget Template - trial.xls").Activate ' select BA Report worksheet Worksheets("BA Report").Activate Worksheets("BA Report").Range("BCostCentre") = c.Value ' initiate workbook calculations Calculate ' Obtain cost centre description to be included in the filename bname = "(" & Worksheets("BA Report").Range("BCostCentreDescription").Value & ")" ' insert desription of entity, cost centre and cost centre description Range("D10:E11").Select Selection.Copy Windows("budget worksheet template1").Activate Range("D10").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ' return to master template Windows("2008-09 Budget Template - trial.xls").Activate ' select data from master template and paste into new work as values Range("G19:H294").Select Selection.Copy Windows("budget worksheet template1").Activate Range("G19").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False 'return to top of sheet in template Range("C15").Select ' create file name in the format of: ' 2340100 - Collection & Content Devel Div - 08.09 BUDGET TEMPLATE.xls fname = c.Value & " - " & bname & " - 08.09 BUDGET TEMPLATE" & ".xls" ' Save worksheet as the fiel name in the directory mentioned above and close ActiveWorkbook.SaveAs Filename:=fname, CreateBackup:=False ActiveWorkbook.Close ' move to the next costcentre in the range Next c ' Reenable screen updating & calculation Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic ' reenable the display of alerts Application.DisplayAlerts = True ' Prompt user on completion MsgBox "Generation of Budget templates completed" End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy and paste up to values in last row | Excel Discussion (Misc queries) | |||
Copy and paste values, formatting and formulas | Excel Discussion (Misc queries) | |||
Copy/Paste how to avoid the copy of formula cells w/o calc values | Excel Discussion (Misc queries) | |||
Copy/Paste Values | Excel Programming | |||
How do i compare values from two sheet and copy & paste if values match? | Excel Programming |