Alright this will be a long post but I will try to re explain my situation in plain english AND address the questions posted by you guys in order....
The situation in plain english:
I have a dataset, an array loaded from a sheet in Excel, with a bunch of integer columns and a date column. The date column holds the date of the friday for each week in the dataset. What I need to do is, for each row, do some comparative math and derive a value using the integer columns. I then need to take this value, and again for each row, compare it against a value that needs to be derived from the array as a whole (not just one row).
to bring up psuedo code again....
(RowLevelField1 + RowLevelField2 + RowLevelField3) / ArrayLevelCalculatedVariableValue
I am thinking that maybe I need another array and/or some more looping. Working with datasets like this would be so much easier in a database
Now to answer all of your questions:
1. SkipVought
1a:
Are you referring to a RANGE on a SHEET, since you refer to ROWS and COLUMNS?
Answer:
By rows/columns I am referring to dimensions in an array
1b:
How are you defining ARRAY, which, BTW, is a VBA Reserve Word (Not an Excel Object)?
Answer:
by ARRAY I mean a specific array, I changed the name of the array to "ARRAY" without considering that it is a key word (sorry!)
1c:
How are you defining Columnn?
Answer:
column in the array
1d:How are you defining EndOfWeek?
date value corresponding the the friday of each week in the data
2. electricpete
2a:
I would assume you are working with an array, since ubound wouldn't work with a range.
Answer:
Correct, an array... not a range
2b:
I would also assume you have renamed the name of the array from some valid name to "array". Array is not a valid name for an array or any other variable... it is a reserved word as identified above.
Answer:
Again correct! I renamed the array without considering that it is a key word.
2c:
And by the way, where are the endofweek values stored? Another field of your database... for example MYARRAY(row).Column4 ... MYARRAY(row).endofweek ?
Answer:
Correct a third time... EndOfWeek is stored as a field in an array.
2d:
What are the permissible values for endofweek ?
Answer:
Dates... friday of each week
2e:
I am guessing you need another loop through your data before you get to your code above to count the number of rows containing each value of endofweek and store them in counter variables for each value of endofweek.
Answer:
I think you are correct! Can you elaborate?
2. mintjulep
3a:
Is EndOfWeek one of the columns in the array? You'd need to loop through and count them.
Answer:
Yes
3b:
I would also assume you have renamed the name of the array from some valid name to "array". Array is not a valid name for an array or any other variable... it is a reserved word as identified above.
Answer:
Again correct! I renamed the array without considering that it is a key word.
3c:
Maintaining your (interesting) syntax, and imagining that the endofweek is stored in column4:
For row = 1 To UBound(ARRAY)
If ARRAY(row).column4 = EndOfWeek then Count = Count + 1
VARIABLE = (CCur(5 * _
ARRAY(row).Column1 + _
ARRAY(row).Column2 / _
ARRAY(row).Coulmn3))
ANSWER = VARIABLE / Count
Next row
Answer:
I don't think this is exactly what I am shooting for... For example ARRAY(row).column4 through ARRAY(row).column10 could all equal EndOfWeek.. kind of an example of what I would want to see as output for ARRAY(row).column4 would be:
EndOfWeek TotalRowsForThisWeek
1/1/1900 6
basically group on EndOfWeek and count the number of rows for that date.
3d:
By the way, you understand that your logic will result in the value of VARIABLE being based solely on whatever is in the LAST row of the array, right?
Answer:
This little bit of code is encapsulated in a couple levels of looping that I think accounts for the issue you are trying to alert me to (although I do not fully understand).