LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Copy and paste formatting and values only

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
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
Copy and paste up to values in last row Scott Excel Discussion (Misc queries) 2 September 23rd 09 10:23 PM
Copy and paste values, formatting and formulas Joe M. Excel Discussion (Misc queries) 2 February 29th 08 09:38 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
Copy/Paste Values briank Excel Programming 5 May 27th 05 05:20 PM
How do i compare values from two sheet and copy & paste if values match? rozb Excel Programming 0 March 5th 04 12:06 AM


All times are GMT +1. The time now is 03:42 AM.

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

About Us

"It's about Microsoft Excel"