ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loading multiple non-contiguous range into an array (https://www.excelbanter.com/excel-programming/389555-re-loading-multiple-non-contiguous-range-into-array.html)

matelot

loading multiple non-contiguous range into an array
 
Jan,
I end up copy and paste the range into an spreadsheet. Then I read the
entire range into an array. That works for me.

Thanks.

"Jan Karel Pieterse" wrote:

Hi Matelot,

I have a selection range that is non-contiguous and want to load them into
an array. It only load the first range.
set rng = range("A1:C2,A9:C10,A15:C18")
myArray = rng.value

Anything wrong with the code? can you suggest on how to best load all the
ranges into an array.


As you have discovered, you can only bulk-read contiguous ranges into an
array. You'll have to loop through the Areas collection of the range and add
each area's cells individually.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com




All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com