Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Is it possible to create variables in a loop..

Hi all,
I failed to figure this out. I am trying to go through about 300 rows
and generate some array of data.I am not interested in all the rows.
Say, I am interested in around 100 rows. Based on some condition I
select these 100 rows and transpose them and save them to a varaible
for further processing. I am doing this in a loop. I wish generate the
variable names, declare them and assign them a value. All these I need
to do in a loop. Could u please suggest..Thanks to all in advance..

Dim DutArray as Varaint
Dim I as Integer
Dim mCell as Range

For I = 1 To 300
Set mCell =
ThisWorkbook.Sheets("SPECS").Range("START_SPEC").O ffset(I, 1)
DutArray = Application.Transpose(Range(mCell,
mCell.End(xlToRight)))

If DutArray(3, 1) = 1 Then

GoTo PROCESSDUT
End If
If DutArray(2, 1) = 1 Then

Here I wish to save the DutArray on to a new variable..
like DUT1, DUT2, DUT3, DUT4 etc...
How can I declare these variables here and then assign some value to
it.?
something like
set "DUT" & I = DutArray

End If
Next

shishi

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Is it possible to create variables in a loop..

That isn't supported. That is why you use arrays. The alternative is to
declare all those variables individually and then put in a line of code for
each variable in which you assign it a value

--
Regards,
Tom Ogilvy


"shishi" wrote in message
ups.com...
Hi all,
I failed to figure this out. I am trying to go through about 300 rows
and generate some array of data.I am not interested in all the rows.
Say, I am interested in around 100 rows. Based on some condition I
select these 100 rows and transpose them and save them to a varaible
for further processing. I am doing this in a loop. I wish generate the
variable names, declare them and assign them a value. All these I need
to do in a loop. Could u please suggest..Thanks to all in advance..

Dim DutArray as Varaint
Dim I as Integer
Dim mCell as Range

For I = 1 To 300
Set mCell =
ThisWorkbook.Sheets("SPECS").Range("START_SPEC").O ffset(I, 1)
DutArray = Application.Transpose(Range(mCell,
mCell.End(xlToRight)))

If DutArray(3, 1) = 1 Then

GoTo PROCESSDUT
End If
If DutArray(2, 1) = 1 Then

Here I wish to save the DutArray on to a new variable..
like DUT1, DUT2, DUT3, DUT4 etc...
How can I declare these variables here and then assign some value to
it.?
something like
set "DUT" & I = DutArray

End If
Next

shishi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Is it possible to create variables in a loop..

No you can not "create" variables in code. workarounds are not worth the
effort.

However to address your project try using a slightly more complex array -
MyArray

where the first dimention is the "name" and the seciond is the value - which
just happens to be an array. So MyArray("Dut2",1) = the array you want to
store as DUT2 (assumes a base zero array)

now MyArray(

"shishi" wrote:

Hi all,
I failed to figure this out. I am trying to go through about 300 rows
and generate some array of data.I am not interested in all the rows.
Say, I am interested in around 100 rows. Based on some condition I
select these 100 rows and transpose them and save them to a varaible
for further processing. I am doing this in a loop. I wish generate the
variable names, declare them and assign them a value. All these I need
to do in a loop. Could u please suggest..Thanks to all in advance..

Dim DutArray as Varaint
Dim I as Integer
Dim mCell as Range

For I = 1 To 300
Set mCell =
ThisWorkbook.Sheets("SPECS").Range("START_SPEC").O ffset(I, 1)
DutArray = Application.Transpose(Range(mCell,
mCell.End(xlToRight)))

If DutArray(3, 1) = 1 Then

GoTo PROCESSDUT
End If
If DutArray(2, 1) = 1 Then

Here I wish to save the DutArray on to a new variable..
like DUT1, DUT2, DUT3, DUT4 etc...
How can I declare these variables here and then assign some value to
it.?
something like
set "DUT" & I = DutArray

End If
Next

shishi


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
Setting Multiple Variables with a loop jlclyde Excel Discussion (Misc queries) 6 November 11th 09 09:40 PM
Write variables from a loop, once only Novaloc Excel Programming 1 October 11th 05 04:10 AM
One solution solved one more to go€¦ Loop & Cell variables? CRayF Excel Programming 4 September 19th 05 05:51 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
Excel VBA - changing variables during a loop ellis_x[_3_] Excel Programming 3 July 5th 04 08:44 AM


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