Hi,
I have developed a Chart with dynamic variables using the combination of OFFSET and MATCH functions to select the data from a table based on dates. I have given below all the formulas and names defined in the workbook.
ChartDates=Chart!$A$26:$A$1048576
EndDate=Chart!$H$22
StartDate =Chart!$E$22
Chart Price (primary) Series is Defined as
XValuesPrice =OFFSET(Chart!$A$26,MATCH(Chart!StartDate,Chart!ChartDates,1)-1,0,MATCH(Chart!EndDate,Chart!ChartDates,1)-MATCH(Chart!StartDate,Chart!ChartDates,1)+1,1)
YValuesPrice =OFFSET(Chart!XValuesClose,0,1)
Chart Volume (secondary) Series is Defined as
XValuesVolume =OFFSET(Chart!$A$26,MATCH(Chart!StartDate,Chart!ChartDates,1)-1,0,MATCH(Chart!EndDate,Chart!ChartDates,1)-MATCH(Chart!StartDate,Chart!ChartDates,1)+2,1)
YValuesVolume =OFFSET(Chart!XValuesVolume,0,2)
There are two lines in the chart one for Price and other for volume.
EndDate and StartDate are dynamic and selected from a data validation list (combo box) for the range I want the graph to be generated.
Now I want to insert a button to predefine the date range for “6 Month”, “3 months”, etc. e.g. if I press the 6 month button the macro should select the right “StartDate” to generate the chart for the 6 month period automatically (if the exact date to define the 6 month period is not available in the data range the macro should select the closest date to 6 month). “Enddate” will remain as current date or the latest date for which data is available.
I am not familiar with VBA coding , I would greatly appreciate if someone can help me with the coding to do the above task.
Regards,
Irshad
Bookmarks