Copy column loop

CZ191279

New Member
Joined
Mar 20, 2019
Messages
3
Dear all,
May I ask your help for a macro which allowed me to copy a range (column) 16350 times :)
On D5 to D369 I have a formula which do a random calculation.
On F4 to XEA4 I have a number from 1 to 16,350
I need a macro which copy the range D5 to D369 on range F5 to F369 (F4=1);G5 to G369 (F5=2) and so on till XEA5 which is the 16,350 columns...
I need the macro ended when it reach the number 16,350 or XEA4
thank you very much for your help
I hope I was clear as a beginner in VBA
thank you
CZ
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
try this:
Code:
For i = 1 To 16350
inarr = Range("D5:D369")
Range(Cells(5, 5 + i), Cells(369, 5 + i)) = inarr
Next i
 
Upvote 0
How about:

Code:
Sub copycolumn()
    Range("D5:D369").Copy Range("F5:XEA5")
End Sub
 
Upvote 0
Code:
[D5:D369].Copy [F5:XEA369]
 
Last edited:
Upvote 0
Thank you very much for the answer but it is not so easy as there is a randow formula on column D i need to copy this column 16350 as i need to have 16350 different result (everytime I copy paste one column the random variable is updated) So I need everytime to copy column D and paste it on F recopy D copy on G .... thank you
 
Upvote 0
Try:

Code:
Sub copycolumn2()
    For i = Columns("F").Column To Columns("XEA").Column
        Range("D5:D369").Copy Cells(5, i)
    Next
End Sub
 
Upvote 0
Have you tried my solution post #2 , I anticipated that you wanted a recalculation in between each copy and my code will do that. I tested it with RAND() functions in column D and each column copied was different
You can force a recalculation by adding this code if you find it necessary:
Code:
Sub test()

For i = 1 To 16350
inarr = Range("D5:D369")
Range(Cells(5, 5 + i), Cells(369, 5 + i)) = inarr
ActiveSheet.EnableCalculation = False
ActiveSheet.EnableCalculation = True
Next i
End Sub
 
Upvote 0
Thank you all for your time after trying the prog of offthelip my file works perfectly thank you again
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,981
Members
448,934
Latest member
audette89

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