Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel training uk - macro optimization

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » excel training uk - Macro Optimization

excel training uk - Macro Optimization

ResolvedVersion 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 courses

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Edit and format multiple worksheets in one operation

To select two or more non-adjacent worksheets, click on the tab of each worksheet, while holding down the [CTRL] key.
To select two or more adjacent worksheets, click on the tab of the first worksheet and then on the tab of the last worksheet, while holding down the [SHIFT] key.
Enter or modify your data and apply the necessary formatting options to the sheet that's displayed

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.