How to read the indices from each element of array?

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
I am reading through the elements of an array with a For Each each loop, but how do I read the coordinates of each element in turn as called, for example:

For Each Element in MyArray
x = (first coordinate/index number of Element)
y = (second coordinate/index number of Element)
Next Element

I know that you can do this the other way round and call each element in turn by looping through the indices directly, but is there some function or property to read the "coordinates" or index numbers of each element in an array as called with a For Each loop?
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Sorry but there's no direct way to do that in VBA.

VBA just doesn't have the same kind of functionality available for arrays as other languages have.
 
Upvote 0
OK, thanks, at least now I can stop waiting and/or searching for an answer. I guess I just do it the normal way, looping through the indices along each dimension directly.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top