Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JP JP is offline
external usenet poster
 
Posts: 103
Default Loop and name

I assign values to range objects from an array. Is is possible to loop this?
My code is:

Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

Set rng2 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)

Set rng3 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(3),
LookIn:=xlValues)

I can easily loop the array but how do you name the rng1, rng2 etc. ? They
are defined as Range. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Loop and name

Make rng an array.

Dim rng(1 to 3) as Range
Set rng(1) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

Set rng(2) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)

Set rng(3) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(3),
LookIn:=xlValues)

for i = 1 to 3
msgbox rng(i).Address(0,0,xlA1,True)
Next

--
regards,
Tom Ogilvy

"JP" wrote:

I assign values to range objects from an array. Is is possible to loop this?
My code is:

Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

Set rng2 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)

Set rng3 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(3),
LookIn:=xlValues)

I can easily loop the array but how do you name the rng1, rng2 etc. ? They
are defined as Range. Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
JP JP is offline
external usenet poster
 
Posts: 103
Default Loop and name

Thanks! The thing is that I need the addresses to all rng:s. I use them like
this e.g.:

..SeriesCollection(1).XValues =
Sheets(varWorksheetInfoArray(0)).Range(rng1.Offset (i, 0).Address & ":" &
rng1.Offset(j, 0).Address)

is it possible to do the same when rng is defined as an array? Thank you
very much for your help!


"Tom Ogilvy" skrev:

Make rng an array.

Dim rng(1 to 3) as Range
Set rng(1) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

Set rng(2) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)

Set rng(3) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(3),
LookIn:=xlValues)

for i = 1 to 3
msgbox rng(i).Address(0,0,xlA1,True)
Next

--
regards,
Tom Ogilvy

"JP" wrote:

I assign values to range objects from an array. Is is possible to loop this?
My code is:

Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

Set rng2 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)

Set rng3 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(3),
LookIn:=xlValues)

I can easily loop the array but how do you name the rng1, rng2 etc. ? They
are defined as Range. Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop and name

..SeriesCollection(1).XValues =
Sheets(varWorksheetInfoArray(0)).Range(rng(1).Offs et(i, 0).Address & ":" &
rng(1).Offset(j, 0).Address)


--
Regards,
Tom Ogilvy

"JP" wrote in message
...
Thanks! The thing is that I need the addresses to all rng:s. I use them
like
this e.g.:

.SeriesCollection(1).XValues =
Sheets(varWorksheetInfoArray(0)).Range(rng1.Offset (i, 0).Address & ":" &
rng1.Offset(j, 0).Address)

is it possible to do the same when rng is defined as an array? Thank you
very much for your help!


"Tom Ogilvy" skrev:

Make rng an array.

Dim rng(1 to 3) as Range
Set rng(1) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

Set rng(2) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)

Set rng(3) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(3),
LookIn:=xlValues)

for i = 1 to 3
msgbox rng(i).Address(0,0,xlA1,True)
Next

--
regards,
Tom Ogilvy

"JP" wrote:

I assign values to range objects from an array. Is is possible to loop
this?
My code is:

Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

Set rng2 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(2),
LookIn:=xlValues)

Set rng3 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(3),
LookIn:=xlValues)

I can easily loop the array but how do you name the rng1, rng2 etc. ?
They
are defined as Range. Thanks!



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
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
How do I create a For loop within a For loop? Linking to specific cells in pivot table Excel Programming 2 January 24th 05 08:05 AM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 03:47 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"