Hi again,
Yes, the only VBA code is that contained in the "M01_ChartData" module.
This is one of those occasions where "native" Excel does about 97% of the work, and the VBA is there just to provide a prettier user-interface.
Aside from the VBA code, the application boils down to assigning the table on the "Graph Data" worksheet to the graph, and then using appropriate VLOOKUP formulas in the table to retrieve data for the month/year selected by the User. You can manually insert values into the "Selected Year" and "Selected Month" cells and observe how the values in the table are updated appropriately.
The VBA code used is simple, but elegant, in that all of the month buttons call the same "InsertMonth" macro, and both of the year buttons call the same "InsertYear" macro. The key to how it works is the use of the Application.Caller property which returns the name of the button which called the routine - the names of all of the month buttons contain the three-letter version of the associated month name, and this value is inserted into the "Selected Month" cell. A similar but very slightly different process is used for the year buttons.
Incidentally, here's a slightly nicer version of the "InsertYear" routine:
You can also use the above technique in conjunction with the month buttons if you prefer. The fundamental difference between the month buttons and the year buttons is that the text (i.e. month name) on the month buttons never changes, whereas the text (i.e. year) on the year buttons is determined by the ranges of the date cells listed on the "Data" worksheet.
Hope you find the above helpful - please let me know how you get on with it.
Regards,
Greg M
Bookmarks