![]() |
pasting data from an array
I want to use a macro to copy data from the same cell in all worksheets and
then paste it row by row in the active worksheet. I'm okay for the code to select and copy, I'm currently using an array (don't know if there is a smarter way). However could someone give me some pointers on the code to use for pasting in the active sheet row by row. Without have to have a line of code for each worksheet. Cheers Laura |
pasting data from an array
You can paste in many ways, some more efficient than others. If you
have the contents of each of the key cells in a 2 dimensional array you can declare a range with the same dimensions on the activesheet and paste with .Value For example: Dim rngDest as Range Set rngDest = ActiveSheet.Range("A1:A5") 'Presuming your array is 5 by 1 rngDest.Value = yourArray Or if you must go row by row: Dim rngCell as Range Dim rngDest as Range Dim iCount as Integer Set rngDest = ActiveSheet.Range("A1:A5") iCount = LBound(yourArray, 1) For each rngCell in rngDest rngCell.Value = yourArray(iCount) iCount = iCount + 1 Next rngCell HTH |
All times are GMT +1. The time now is 05:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com