All,
I am new to VBA, but I am trying to write a bit of code to download financial data from Yahoo, store it temporarily in a spreadsheet, copy the data to an array and repeat for X number of times (X = the number of stocks the user wants to evaluate).
Array (i, j, k)
i = the number of rows or the days of information that the user wants to evaluate. This is unknown until the very first loop (look at the first stock data pulled down by yahoo, weekends and holidays make it this way).
j = the number of columns of data collected for each stock. This is 7 or 6 in the case of an array as it is 0 based (0, 1, ... 6). So j is always 6
k = the number of stocks or layers to my array cube of data that I am looking to build. I don't know this until the user input is gathered (Ex, they want to look at 10 stocks, I know I should set k to 9.
How can I correctly dim the array in the beginning of the code with all my other variables and then in the first loop (I have the logic to determine this sum(all counters) = 0 is only true in the very first loop (looking at first row/column of data in the first stock).
Dim array() ????
After the size is known (iMax is a variable set to the value of the number of rows -1 for 0 base, similar for kMax and the number of stocks to evaluate)
Redim array (iMax, 6, kMax)
This seems like the basic idea, but i can't seem to get to to work correctly. At the point I redim, I do not have any data that I care about in the array (preserve not needed). The easy solution is to set iMax = 30 (never 30 days of trading in 30 days and just limit the search range to a month or less) and similar for kmax, but that would leave a HUGE amount of wasted memory.
Thanks,
Mark
Bookmarks