Create an array from selected rows from Named Table

IlyaK

New Member
Joined
Apr 18, 2016
Messages
23
Hello everyone!

Can't solve a problem..
There is a named table on sheet. User selecting one or several rows and starting a macro.
The point is to make 2-D array with columns and rows, selected by user.
I use a "union(r1, r2..)" statement to make consolidated range that I want to insert in array,
but it has a strange behaviour: if I try to apply cons_range.rows.count, I get 1, neverthless in range are more rows.
There is thoughts about using consolidate() statement on proxy sheet, but how to get data from it without creating named table there..

Thanks for all suggestion!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Your Union range will have multiple areas that you need to loop through. The Rows property will only apply to the first area if you apply it directly to the result of the Union operator.
 
Upvote 0
Thnx, Rory! But how to loop through set of rows?
When I loop by Range.Cells(), excel don't warning me about UpBound of set_of_range and returning me values from last row without any error.
How could I figure out UpperBound to limit the loop?
Sorry for "stream of consciousness" :)[FONT=&quot]
[/FONT]
 
Upvote 0
As I said, you need to loop through the areas - for example:

Code:
for each rg in UnionRange.Areas
   for each rw in rg.Rows
      ' do something
   next rw
next rg
 
Upvote 0
Of course! Areas! ? You're my hero! ?

May be you could suggest me a way to fill an array without looping through all selected ranges. I already make it through ref_table on hidden sheet, but it should be approach without using other objects..
Anyway thx a lot!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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