LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default Determining number of values in an array (2 related questions)

Using XL2003 on Win2000

I'm setting up a workbook for other folks to use; they may edit the number
of elements in several arrays (which I've hardcoded at the top of the module
so they can find them):

MyArrayOfStudentNames =Array("Name1", "Name2", "Name3")
MyArrayOfStudentGradeLevel =Array("7", "3", "12")

Here's my first problem; I want to allow them to declare/fill a
one-dimensional array of _numbers_. I /could/ have them put each number in
quotes, then pull the value out in code- but that wastes processing power.
Is there any way to declare a one-dimensional array by populating it with
numbers? The following _doesn't_ work because it appears to create a
multidimensional array with three dimensions of (0 to 7, 0 to 3, and 0 to
12):

MyArrayOfStudentGradeLevel =Array(7, 3, 12)

Then my second problem comes into play;

Since I don't know how many items will be in the one-dimensional array (once
I learn how to dimension it), my code needs to use each value then stop
after the last one without erroring. I was going to use a loop:

For each StudentGradeLevel = 1 to 10
'do stuff
Next

but in the above example, only 3 items exist, so the array is actually
dimensioned as a (1 to 3) or (0 to 2) array; my loop will error out because
my array isn't that large. To code defensively, how do I determine how many
items are in the array first, so I can make that the maximum of my loop?
Items may not be sequential, so what I really need is the maximum array
value regardless of whether it is filled (e.g. could be Array(3,5, ,12,6, )
and should return that there are 6 items to be looped through)

Thanks bunches and bunches in advance,
Keith

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.


 
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
delete row formula changes array range on related sheet Robert Excel Worksheet Functions 8 July 4th 09 09:18 AM
2 questions! Related to combobox and time function. HELP!! Bruno Excel Discussion (Misc queries) 11 September 28th 07 02:33 PM
Summing Related Values Adam1 Chicago Excel Discussion (Misc queries) 1 March 9th 05 09:38 PM
Determining Array Limit Chaplain Doug Excel Programming 3 January 5th 05 01:37 AM
2 questions related to Excel under Windows 98/2000 Gaston AGON Excel Programming 2 April 7th 04 11:01 AM


All times are GMT +1. The time now is 12:26 AM.

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"