I do have a large data set which has hourly data for some amount of years: I want to make a 4 dimensional array which has the following form:
To get the amount of years i have to find the last observed data and then compare it to the first one, to do so i need the amount of used rows.
Dim YearAmount As Integer
Const Lastrow As Long = Sheets(1).Cells(Sheets(1).Rows.Count,"A").End(xlUp).Row
'This returns an error, saying "Constant expression required"
YearAmount=Datediff("yyyy", Range("A2").Value , Range("A" & Lastrow ).Value) + 1
Dim Data(1 to YearAmount,1 to 12,1 to 31,0 to 23) as Double
I don't know how to get arround properly dimensioning my Data array, should i initialize it as a variant array and then use the ReDim method?, and if so, how would i go about resizing to more dimensions?
Trying to declare LastRow and YearAmount as constants didn't work, since vba yells that i'm trying to set a function return value as the constant, this I do not know how to get around.