Confusing Piece of VBA Code
I'm trying to come to grips with someone else's spreadsheet and am having trouble with some of the VBA code. Here is an example of it (the original is similar to this just a lot longer):
Code:
Public Sub Set_Z2()
Z2(1, 1, 0) = 5
Z2(1, 1, 1) = 0.62
Z2(1, 1, 2) = 0.79
Z2(1, 1, 3) = 0.89
Z2(1, 1, 4) = 0.97
Z2(1, 1, 5) = 1.02
End Sub
The part I don't understand is the bit in brackets. "Z2" is (I'm pretty sure) supposed to be a variable but why is it followed by 3 numbers in brackets?
Cheers
-Rob
Re: Confusing Piece of VBA Code
Its a 3 dimensional array. How is it defined - dynamic bounds or is it a static declaration of elements? What type double?
Re: Confusing Piece of VBA Code
Code:
Public Z2(1 To 2, 1 To 12, 0 To 5) As Single
There's also this bit:
Code:
Public summer(100) As Single
Public Winter(100) As Single
So I take it that means that this declares two variables (summer and winter) as Single variables but also as arrays with 100 (or 101?) elements?
Re: Confusing Piece of VBA Code
Yes, 101 unless you have an Option Base 1 statement at the top of the class/module. :thumb: