Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Storing multiple ranges using a macro

I have to play with lot of ranges in a worksheet. Say range1 is from
A1:A10, range2 is from B1:B10 and so on. I have 1000s of such ranges.

One of doing it is defining individial ranges say

dim range1 as range
dim range2 as range
.....
....
....

etc.

I dont want to use 1000 variables for 1000 different ranges. Is there
any way of creating an array of ranges? OR Whats the best way of
doing it?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Storing multiple ranges using a macro

Is this what you're after?

Set myRange = Union(myRange1, myRange2, myRange3)
--
HTH,
Barb Reinhardt



"Chaman" wrote:

I have to play with lot of ranges in a worksheet. Say range1 is from
A1:A10, range2 is from B1:B10 and so on. I have 1000s of such ranges.

One of doing it is defining individial ranges say

dim range1 as range
dim range2 as range
.....
....
....

etc.

I dont want to use 1000 variables for 1000 different ranges. Is there
any way of creating an array of ranges? OR Whats the best way of
doing it?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Storing multiple ranges using a macro

You can create a collection of ranges but as a guess you probably want to
create a single range object and just keep on re-defining it as is
necessary...

dim rngToSort as Range

set rngToSort = range("A1:A10")
rngToSort.sort ...
set rngToSort = rngToSort.offset(0, 1)
rngToSort.sort ...

--
HTH...

Jim Thomlinson


"Chaman" wrote:

I have to play with lot of ranges in a worksheet. Say range1 is from
A1:A10, range2 is from B1:B10 and so on. I have 1000s of such ranges.

One of doing it is defining individial ranges say

dim range1 as range
dim range2 as range
.....
....
....

etc.

I dont want to use 1000 variables for 1000 different ranges. Is there
any way of creating an array of ranges? OR Whats the best way of
doing it?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Storing multiple ranges using a macro

Barb, Thanks for your effort. Union will combine all my ranges and I
dont seek to do that. I just want to store the individual ranges
using a single variable.

Jim, Thanks to you too. I want to create a collection of ranges using
a single variable (say an array of ranges). I dont want to keep on re-
defining my single range variable again and again.

Can you guys help me now? I hope I'm able to explain it more clearly
now. Any help would be greatly appreciated.

On Aug 22, 12:50*pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
You can create a collection of ranges but as a guess you probably want to
create a single range object and just keep on re-defining it as is
necessary...

dim rngToSort as Range

set rngToSort = range("A1:A10")
rngToSort.sort ...
set rngToSort = rngToSort.offset(0, 1)
rngToSort.sort ...

--
HTH...

Jim Thomlinson



"Chaman" wrote:
I have to play with lot of ranges in a worksheet. *Say range1 is from
A1:A10, range2 is from B1:B10 and so on. *I have 1000s of such ranges..


One of doing it is defining individial ranges say


dim range1 as range
dim range2 as range
.....
....
....


etc.


I dont want to use 1000 variables for 1000 different ranges. *Is there
any way of creating an array of ranges? *OR Whats the best way of
doing it?- Hide quoted text -


- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing multiple ranges using a macro Chaman Excel Discussion (Misc queries) 1 August 22nd 08 06:11 PM
Record macro to name multiple ranges sancht Excel Programming 2 March 7th 07 01:12 AM
Macro Help (Uppercase multiple ranges?) Ken Excel Discussion (Misc queries) 14 December 2nd 06 07:23 PM
Print macro for multiple ranges/sheets William[_2_] Excel Programming 0 June 1st 04 11:29 PM
Print macro for multiple ranges/sheets Ron de Bruin Excel Programming 1 June 1st 04 10:56 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"