ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple range selection (https://www.excelbanter.com/excel-programming/369875-multiple-range-selection.html)

I. N. Manoussopoulos

Multiple range selection
 
Hi,
Could someone help in the following problem?
I need to select several ranges of different sizes simultaneously. While I
have managed to select and store all of them separately, in an array, I
haven't been able to recall and "merge' them after storage, in a single
multiple range. I have tried to do so using the Union method but it is
impossible to write 80 to 90 objects in it, to be merged. Is there any else
more efficient method or code?
Thanks a lot



NickHK[_3_]

Multiple range selection
 
You have a few options that can be combined:
1 - Used Named ranges: select some of the ranges that are related and give
them a name in the drop down at the top left e.g. rngData1
2 - Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
set rng1=range("A1:G6,H7,M89:U100,rngData1)
set rng2=range("C13,D15:F67)
3 - set rng3=Union(rng1,rng2)
rng3.select
The limit on a Union is 30 ranges, but you can build those from the other
techniques.

NickHK

"I. N. Manoussopoulos" ...
Hi,
Could someone help in the following problem?
I need to select several ranges of different sizes simultaneously. While I
have managed to select and store all of them separately, in an array, I
haven't been able to recall and "merge' them after storage, in a single
multiple range. I have tried to do so using the Union method but it is
impossible to write 80 to 90 objects in it, to be merged. Is there any
else
more efficient method or code?
Thanks a lot





I. N. Manoussopoulos

Multiple range selection
 
Thanks for the advise,

I was also thinking on the possibility of using a loop, or a function for
doing this, as manipulating all these variables by hand increases the chance
for errors. I was thus wondering whether the Union method could be part of
a For Next (and the like) construction of the form
set rg(i)= Union(rg(i), Rg(i+1))

Best regards






"NickHK" wrote in message ...
You have a few options that can be combined:
1 - Used Named ranges: select some of the ranges that are related and give
them a name in the drop down at the top left e.g. rngData1
2 - Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
set rng1=range("A1:G6,H7,M89:U100,rngData1)
set rng2=range("C13,D15:F67)
3 - set rng3=Union(rng1,rng2)
rng3.select
The limit on a Union is 30 ranges, but you can build those from the other
techniques.

NickHK

"I. N. Manoussopoulos"

...
Hi,
Could someone help in the following problem?
I need to select several ranges of different sizes simultaneously. While

I
have managed to select and store all of them separately, in an array, I
haven't been able to recall and "merge' them after storage, in a single
multiple range. I have tried to do so using the Union method but it is
impossible to write 80 to 90 objects in it, to be merged. Is there any
else
more efficient method or code?
Thanks a lot








All times are GMT +1. The time now is 12:39 PM.

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