Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default about ARRAY variable

people, maybe my question sounds very stupid, but i try to ask you

i have array variable

for exampl.

dim ddd(2)
ddd(0)="aaa"
ddd(1)="bbb"
ddd(2)="ccc"


for each cc in ddd

msgbox cc.index

PEOPLE !, is there any property on array using which i can ge
current index of array ?????????????????


I dont want to use For statement.....

i simply want to know how to get INDEX of array


next



thank

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default about ARRAY variable

Marek,

You can either keep track of the index:

Sub TryNow2()
Dim ddd(0 To 2) As String
Dim cc As Variant
Dim myCount As Integer

ddd(0) = "aaa"
ddd(1) = "bbb"
ddd(2) = "ccc"

myCount = LBound(ddd) - 1

For Each cc In ddd
myCount = myCount + 1
MsgBox "Element " & myCount & " is " & cc & "."
Next cc

End Sub

OR, simply use the index when stepping through:

Sub TryNow()
Dim i As Integer
Dim ddd(0 To 2)

ddd(0) = "aaa"
ddd(1) = "bbb"
ddd(2) = "ccc"

For i = LBound(ddd) To UBound(ddd)
MsgBox "Element " & i & " is " & ddd(i) & "."
Next i
End Sub

HTH,
Bernie
MS Excel MVP


"Marek " wrote in message
...
people, maybe my question sounds very stupid, but i try to ask you

i have array variable

for exampl.

dim ddd(2)
ddd(0)="aaa"
ddd(1)="bbb"
ddd(2)="ccc"


for each cc in ddd

msgbox cc.index

PEOPLE !, is there any property on array using which i can get
current index of array ?????????????????


I dont want to use For statement.....

i simply want to know how to get INDEX of array


next



thanks


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default about ARRAY variable

Hi, Bernie:

If the index is needed, I would certainly use that index as the variable in
the For/Next loop. My problem with 'For Each' is that I'm not completely
confident as to the order in which the members of the collection are
processed. Does it always start at the bottom and move up, or from the top
moving down? I haven't seen any documentation on this point, have you?



On Mon, 13 Sep 2004 12:33:11 -0400, "Bernie Deitrick" <deitbe @ consumer dot
org wrote:

Marek,

You can either keep track of the index:

Sub TryNow2()
Dim ddd(0 To 2) As String
Dim cc As Variant
Dim myCount As Integer

ddd(0) = "aaa"
ddd(1) = "bbb"
ddd(2) = "ccc"

myCount = LBound(ddd) - 1

For Each cc In ddd
myCount = myCount + 1
MsgBox "Element " & myCount & " is " & cc & "."
Next cc

End Sub

OR, simply use the index when stepping through:

Sub TryNow()
Dim i As Integer
Dim ddd(0 To 2)

ddd(0) = "aaa"
ddd(1) = "bbb"
ddd(2) = "ccc"

For i = LBound(ddd) To UBound(ddd)
MsgBox "Element " & i & " is " & ddd(i) & "."
Next i
End Sub

HTH,
Bernie
MS Excel MVP


"Marek " wrote in message
...
people, maybe my question sounds very stupid, but i try to ask you

i have array variable

for exampl.

dim ddd(2)
ddd(0)="aaa"
ddd(1)="bbb"
ddd(2)="ccc"


for each cc in ddd

msgbox cc.index

PEOPLE !, is there any property on array using which i can get
current index of array ?????????????????


I dont want to use For statement.....

i simply want to know how to get INDEX of array


next



thanks


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default about ARRAY variable

Myrna,

I have never seen any documentation as to how Excel moves through arrays
when 'For Eaching' them, but in my experience, it always starts at the lower
bound and progresses up - the two subs that I posted return them in the same
order. Seems to work that way with cells, worksheets, workbooks, etc.

Of course, under closer questioning, I would admit "If Myrna doesn't know
for sure, then I certainly don't!" ;-)

Bernie

"Myrna Larson" wrote in message
...
Hi, Bernie:

If the index is needed, I would certainly use that index as the variable

in
the For/Next loop. My problem with 'For Each' is that I'm not completely
confident as to the order in which the members of the collection are
processed. Does it always start at the bottom and move up, or from the top
moving down? I haven't seen any documentation on this point, have you?



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
Using COUNTA for a variable array Schannah Excel Worksheet Functions 5 July 22nd 08 05:02 PM
Variable column to fixed array asaylor Excel Worksheet Functions 0 August 9th 06 05:28 PM
use a variable array in a formula JPderose Excel Discussion (Misc queries) 1 October 20th 05 06:24 AM
Variable Array Problem mudraker[_37_] Excel Programming 3 November 26th 03 12:43 AM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 10:32 PM.

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

About Us

"It's about Microsoft Excel"