How to copy lines of data FAST !

hhenrion

Board Regular
Joined
Dec 19, 2005
Messages
73
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 ?

Thanks in advance,
regards,

H.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
How are you doing it at the moment? By hand? By macro?
 
Upvote 0
MACRO

Hi Glenn,

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

Rgds,

H.
 
Upvote 0
In that case post the current macro. There may be something simple to change to improve performance.
 
Upvote 0
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.
 
Upvote 0
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 ).
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

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