# How to copy lines of data FAST !

#### hhenrion

##### Board Regular
Hi experts,

I have a lot of data in one sheet (distributed on many lines, sometimes consecutive, sometimes not) covering each time 60 consecutive rows.

I need to copy them, apply a mathematical formula, and paste the value in a different sheet.

I am copying in a 2 dimensional table, processing, and pasting.
And it take ages...

What is the fastest way of passing lines of 60 rows of data in a table ?

regards,

H.

### Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How are you doing it at the moment? By hand? By macro?

MACRO

Hi Glenn,

one piece of information I had forgotten to mention : I use a MACRO.

Rgds,

H.

In that case post the current macro. There may be something simple to change to improve performance.

Macro - Text

Here it is :

Sheets("Prod").Select
For i = 1 To 6
For j = 1 To 10
For k = 1 To 60
Prod((i - 1) * 10 + (j - 1) * 4 + 1, k) = Range("F17").Offset((i - 1) * 200 + (j - 1) * 7, k - 1).Value
Prod((i - 1) * 10 + (j - 1) * 4 + 2, k) = Range("F17").Offset((i - 1) * 200 + (j - 1) * 7 + 1, k - 1).Value
Prod((i - 1) * 10 + (j - 1) * 4 + 3, k) = Range("F62").Offset((i - 1) * 200 + (j - 1) * 7, k - 1).Value
Prod((i - 1) * 10 + (j - 1) * 4 + 4, k) = Range("F62").Offset((i - 1) * 200 + (j - 1) * 7 + 1, k - 1).Value
Next k
Next j
Next i
Sheets("Scen").Select
For ij = 1 To 120
For k = 1 To 60
Range("SC_TOP_PCO").Offset(ij, 2 + k).Value = Prod(ij, k)
Next k
Next ij

Rgds,

H.

Looking at your logic, you are copying contiguous blocks ( 60 cells per row ), from one sheet to another, but are doing one cell at a time instead of a block at a time, and are storing it in an array in between. You can put the values directly in the second sheet without going through an array, and do a block at a time like this:
Code:
``````Sheets("Prod").Select
For i = 1 To 6
For j = 1 To 10
Sheets("Scen").Range("SC_TOP_PCO").Offset((i - 1) * 10 + (j - 1) * 4 + 1, 3).Resize(, 60) = Range("F17").Offset((i - 1) * 200 + (j - 1) * 7, 0).Resize(, 60).Value
Sheets("Scen").Range("SC_TOP_PCO").Offset((i - 1) * 10 + (j - 1) * 4 + 2, 3).Resize(, 60) = Range("F17").Offset((i - 1) * 200 + (j - 1) * 7 + 1, 0).Resize(, 60).Value
Sheets("Scen").Range("SC_TOP_PCO").Offset((i - 1) * 10 + (j - 1) * 4 + 3, 3).Resize(, 60) = Range("F62").Offset((i - 1) * 200 + (j - 1) * 7, 0).Resize(, 60).Value
Sheets("Scen").Range("SC_TOP_PCO").Offset((i - 1) * 10 + (j - 1) * 4 + 4, 3).Resize(, 60) = Range("F62").Offset((i - 1) * 200 + (j - 1) * 7 + 1, 0).Resize(, 60).Value
Next j
Next i``````
Let me know if it doesn't work ( done in a hurry ).

Thxs

tanks a lot,

regards,

Hervé

Replies
1
Views
240
Replies
6
Views
144
Replies
2
Views
333
Replies
2
Views
624
Replies
3
Views
249

1,217,257
Messages
6,135,503
Members
449,945
Latest member
noone12344444444

### 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.

### Which adblocker are you using?

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

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