Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Looping through each element of an array

Hello All,

Is there better code for looping through each element in an array than

For pintIndex = 0 to 7
'do stuff in pstrArrayName(pintIndex)
Next pintIndex


I was hoping for something like a For...Each statement.

For each (element) in pstrArrayName
'do stuff
Next (element)

Thanks for any help anyone can provide,

Conan Kelly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Looping through each element of an array

Conan Kelly

maybe something like:

For pintIndex = lbound(pstrArrayName) to ubound(pstrArrayName)
'do stuff in pstrArrayName(pintIndex)
Next pintIndex

assuming the number of elements varies (and that's what you are trying to
overcome)

Regards

Trevor


"Conan Kelly" <CTBarbarin at msn dot com wrote in message
...
Hello All,

Is there better code for looping through each element in an array than

For pintIndex = 0 to 7
'do stuff in pstrArrayName(pintIndex)
Next pintIndex


I was hoping for something like a For...Each statement.

For each (element) in pstrArrayName
'do stuff
Next (element)

Thanks for any help anyone can provide,

Conan Kelly



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Looping through each element of an array

Thanks for the info, Trevor.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looping through each element of an array

As you hoped:

For Each Elem in pstrArrayName
Debug.print Elem
Next

Alan Beban

Conan Kelly wrote:
Hello All,

Is there better code for looping through each element in an array than

For pintIndex = 0 to 7
'do stuff in pstrArrayName(pintIndex)
Next pintIndex


I was hoping for something like a For...Each statement.

For each (element) in pstrArrayName
'do stuff
Next (element)

Thanks for any help anyone can provide,

Conan Kelly


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
Permutations of an array element < to a value Bruce Excel Worksheet Functions 3 January 31st 06 04:00 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
Getting Value of Array element in Immediate Window Jim May Excel Programming 5 July 27th 05 01:36 PM
Array element Andrea[_8_] Excel Programming 5 December 7th 04 08:24 PM


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