PDA

View Full Version : Copy selective columns from one worksheet to another in the same workbook



ULAuto
09-26-2017, 08:11 AM
Is there a way to select some columns from a worksheet and copy those in another worksheet in the same workbook? I can do it using the vba macro, but that's slow. so I'm trying to do it by using SQL where first worksheet can be treated as a db table. any help would be greatly appreciated!

Thank you
Nick

offthelip
09-27-2017, 01:52 AM
I can do it using the vba macro, but that's slow.

If you are finding that VBA is slow, I suspect that it is because you are not writing your VBA in a "fast" style.
I started a thread sometime ago which compared different methods of copying data from one sheet to another, different methods had radically different times. One method took 0.34 seconds another common method took 18.12 seconds.
So if you are thinking of using SQL just to speed things up, I suggest you check that you have exhausted the possibilities of speeding up VBA.
See this thread:
http://www.vbaexpress.com/forum/showthread.php?60306-loading-a-variant-array

mdmackillop
09-27-2017, 03:41 AM
Crosspost https://stackoverflow.com/questions/46415416/copy-selective-columns-from-one-worksheet-to-another-in-the-same-workbook