The problem: I would like to create a dynamic array that change size when an event occurs (Event Calculate), by preserving its content and extending by one its size. Let's say I want to do this for a vector of double (and also a date type). The data is updating in a specific cell.
My understanding: I am coding in the Event "Calculate of Excel". I cannot use "Public", I have to declare the array as private and then use Get and Let Property... But, how can I use Redim Preserve in this case ? Also, I think I am probably missing some points on how it has to be used: Here s a sample of the code I wrote:
Name of the Classe: "Class1" Code of the class:
Code:
Option Explicit
Private IntradayValueSerie1() As Double 'Dynamic vector which will contain Y1 Values
Public Counter As Long
Public Property Let vIntradayValueSerie1(ByVal Counter_Value As Long)
IntradayValueSerie1(Counter_Value) = Sheets("Sheet1").Range("C5")
End Property
Public Property Get vIntradayValueSerie1(ByVal Counter_Value As Long) As Variant
vIntradayValueSerie1(Counterr) = IntradayValueSerie1
End Property
So I want "Let" To attribute the new value of my extended array I want "Get" to return the array (extended and updated) Remark: Counter will be updated and increase at then end of the in the section Event "Worksheet.Calculate"
Test code (HAS TO BE in the section Event "Worksheet.Calculate")
Code:
counter = 1
Dim Serie1 As New Class1
Serie1.IntradayValueSerie1(Counter) = ??? I don't know how to use the property to initialize the vector
counter = counter +1
ReDim Preserve IntradayValueSerie1(Counter)
Also, As I want to return an array, do I have to set Variant for the Get property ? As you can see, some points make me confused, either on the use and the structure.
Thank you for you time !