Copy and paste on loop for a set range

chris priyesh

New Member
Joined
May 10, 2014
Messages
7
Dear Experts, need your help.

I am working on a huge excel file with over 50k rows. I have a formula in Cell L2. If i use filldown, the excel is taking too long to process. My idea is to copy the formula in L2, paste it in the remaining cells of column L (i.e., from L3 to the end), then copy and paste the cells from L3 to the end as values.

Considering the speed, i wanted to do it on a loop for every 500 Cells. The steps would be as follows:

Step 1: Set Range based on Column A
Step 2: Copy formula in L2
Step 3: Paste in L3 : L503
Step 4: Copy L3:L503 and paste special -values in L3:L503
Step 5: Copy Formula in L2
Step 6: Paste in L504 : L1004 ...
Continue till range is filled.

I came up with the following Code. But the code is not dynamic and is not working. can you guys help me. Thanks in advance

Code:
Sub Fill()
Dim i As Long
For i = 1 To Range("a1", Range("a" & Rows.Count).End(xlUp)).Value
Range(B2).Select
Selection.Copy
 Range("B2:B" & i).Select
    Selection.FillDown
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

Next i


End Sub

 
Eliminate the Calculate lines in the code and only recalculate after the last copy and paste has been completed. See if that makes a difference
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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