Loops are for noobs just a joke, but with some truth to it.
loops are a nice way to learn VBA and can be usefull in many cases but not for copying large ranges. there are far better options for that.
there is no need to copy cell by cell. if you want to copy and paste 1 area whether it is 8 cells or 8 miljon cell you can do that in one codeline without looping..
so yes vba can handle large datasets when they are handled in the right way..
I think this is all you need for the copy.
to explain..
.Usedrange is the VBA version of CTRL+A or select all this is usefull when the exact data size is not known but all data is in one range and no other data
But there are many other ways to control the size of the copy range. depending on your needs..
sheet1. is the codename of the sheet you called with sheets("sheet1") advantage is that when you change the sheetname on the tab from sheet1 to "rawdata" the codename is still sheet1 and code will run without change when using your version you also need to change the name in the code. That is why I prefer the codename as it is more failsafe
__
also for your testdata set you can use a different code that is not that slow as your loop..
see attachment, generating the testdata is still a few seconds but copying is a splitsecond
Bookmarks