98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » excel training uk - Macro Optimization
excel training uk - Macro Optimization
Resolved · Low Priority · Version Standard
James has attended:
Excel VBA Intro Intermediate course
Macro Optimization
Hi,
I would like to speed up a lengthy multiple copy paste macro. I have used:
Application.ScreenUpdating = False
Application.ScreenUpdating = True
I have attempted to use various ways to bypass the clipboard as well, but can not find a solution that works. The approximate approaches I have used thus far are at the bottom of this message. I have tried variations on the below and I have been using names. So Sheet2.Range("B1:B200") I have replaced with Range("SectionCopy").
I am copying a row of cells with formulas and pasting the values into the row of cells below.
Please can you help me find a solution.
Thanks,
James
'Instead of:
Sheet1.Range("A1:A200").Copy
Sheet2.Range("B1").pasteSpecial
Application.CutCopyMode=False'Clear Clipboard
'Use:
'By-passes the Clipboard
Sheet1.Range("A1:A200").Copy Destination:=Sheet2.Range("B1")
'Or, if only values are needed:
Sheet2.Range("B1:B200").Value= Sheet1.Range("A1:A200").Value
'Or, if only formulae are needed:
Sheet2.Range("B1:B200").Formula = Sheet1.Range("A1:A200").Formula
'See also FormulaArray and FormulaR1C1 etc
'Instead of:
Sheet1.Range("A1:A200").Copy
Sheet1.Range("A1:A200").PasteSpecial xlPasteValues
Application.CutCopyMode=False'Clear Clipboard
'Use:
Sheet1.Range("A1:A200") = Sheet1.Range("A1:A200").Value
RE: Macro Optimization
Hi James
The speed difference between the options you showed is so small that there isn't a stand out method.
I woulsn't bother about naming the range and use
Sheet2.Range("B1:B200").Value= Sheet1.Range("A1:A200").Value
to prevent the use of the clipboard.
Regards
Carlos
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Shortcuts for working with named ranges in ExcelIf you are working with or creating named ranges in your spreadsheets, then you may find the following shortcut keys useful. |