Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Simplify Code for Copy/Paste Special

Thank you - will test out the code and see how it turns out. much
appreciated.

On Sep 2, 5:01*pm, J. Andrew Smith
wrote:
Rule #1: *Never* use Cut Copy and Paste methods in macros, because the user
might be multi-tasking, and you're messing with the *Window* clipboard.

OK, here's how to do all this without CCP, and faster too:

* * With Application
* * * * .Calculation = xlCalculationManual
* * * * .ScreenUpdating = False
* * End With

* * With Worksheets("Interest")

* * * * With .Range("DI28", .Range("E29").End(xlDown)) ' Define upper right
to lower left corners of whole range

* * * * * * .Rows(1).AutoFill .Cells, xlFillCopy ' copies formulas with
relative addressing
* * * * * * Application.Calculate ' recalculates formulas
* * * * * * .Cells.Value = .Cells.Value ' replaces formulas with values

* * * * End With

* * * * .Range("G5").Value = Now() ' Not the Excel function, the VBA function

* * End With

* * With Worksheets("Principal")
* * * * ' same code block
* * End With

--
J. Andrew Smith
Senior Systems Analyst
Standard & Poor''''''''s, NYC

"Active VBA" wrote:
Is there a way to simplify this code below?
If you could please suggest a revised code, it would be greatly
appreciated. Thanks.


Sub update_analysis()
'
' Macro recorded July 2008
'


'
* * Application.ScreenUpdating = False
* * Sheets("Interest").Select
* * Range("E28:DI28").Select
* * Selection.Copy
* * Range("E29").Select
* * Range(Selection, Selection.End(xlDown)).Select
* * Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
* * * * False, Transpose:=False
* * Application.CutCopyMode = False
* * Selection.Copy
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False
* * Range("G5").Select
* * ActiveCell.FormulaR1C1 = "=NOW()"
* * Selection.Copy
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False
* * Sheets("Principal").Select
* * Range("E28:DI28").Select
* * Selection.Copy
* * Range("E29").Select
* * Range(Selection, Selection.End(xlDown)).Select
* * Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
* * * * False, Transpose:=False
* * Application.CutCopyMode = False
* * Selection.Copy
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False
* * Range("G5").Select
* * ActiveCell.FormulaR1C1 = "=NOW()"
* * Selection.Copy
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False
* * * * * * Sheets("Leasing Analysis").Select
* * Range("A2").Select
* * Application.ScreenUpdating = True
End Sub


Thank you for your help in advance.


Best regards,


Active VBA


*** Sent via Developersdexhttp://www.developersdex.com***


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
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Automating copy/paste/paste special when row references change Carl LaFong Excel Programming 4 October 8th 07 06:10 AM
help w/ generic copy & paste/paste special routine DavidH[_2_] Excel Programming 5 January 23rd 06 03:58 AM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM
Copy Paste Special Value using Code over Several Worksheets John[_81_] Excel Programming 1 April 19th 04 12:09 PM


All times are GMT +1. The time now is 11:46 PM.

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"