Optimising VBA Code - For loop

jdmc45

Board Regular
Joined
May 8, 2011
Messages
146
Office Version
  1. 365
Platform
  1. Windows
I want to optimise my VBA code for a large for loop.

I am looping through each time, recalculating some data, and copying and pasting
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
I think I can optimise the following code:
Code:
CurrWS.Range("fin_output").Copy
Dest.PasteSpecial xlPasteValues
Application.CutCopyMode = False

To something like:
Code:
CurrWS.Range("fin_output").Copy Destination:=OutputWS.Range("a1").Value

Which doesn’t use copy/paste with the clipboard which should save time. But it doesn’t seem to work.
<o:p> </o:p>
I have also included

<o:p>
Code:
<o:p></o:p>
Application.ScreenUpdating = False
</o:p><o:p> </o:p>
<o:p></o:p>
Which should speed up the code. Also, is there a way to not use a for loop at all in favour of some other method that is much faster?
<o:p> </o:p>
Any help is much appreciated.
<o:p> </o:p>
James
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
As you are only taking the values, simply assign the value of one range to the other, like:
Code:
OutputWS.Range("A1:A10").Value = CurrWS.Range("A1:A10").Value
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,777
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top