excel training uk - macro optimization

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

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

excel training uk - Macro Optimization

resolvedResolved · 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 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:

Shortcuts for working with named ranges in Excel

If you are working with or creating named ranges in your spreadsheets, then you may find the following shortcut keys useful.

- Bring up the Define Names dialogue box on screen by using Ctrl + F3 (instead of going to Insert - Names).

- Create Names from labels you have entered into the spreadsheet by highlighting the labels and related figures, then hold down Shift + Ctrl + F3. You can then choose to create names from the top or bottom rows, or left or right columns.

- Go directly to a named range by hitting the F5 key. The Go To dialogue box will open and display any named ranges in the spreadsheet. Simply select the named range to navigate to it in the spreadsheet.

View all Excel hints and tips


Server loaded in 0.08 secs.