I would like the ability for the user to enter a year (e.g. “2013”) in cell D1 and press a button that fires off a macro. This macro will automatically assign a function to cells D2-O2 (one cell for each month in the year) that converts these cells to actual date types.
For instance, cell D2’s value would be =DATE(2013, 1, 1), signifying that this cell represents January 1st of 2013. Similarly, cell E2’s value would be =DATE(2013, 2, 1), F2’s value would be =DATE(2013, 3, 1), etc.
The following is my pseudo code, could you please help me convert this to actual VBA?
var myYear = the value of cell D1
cell D2 value is =DATE(2013,1,1)
cell E2 value is =DATE(2013,2,1)
cell F2 value is =DATE(2013,3,1)
cell G2 value is =DATE(2013,4,1)
cell H2 value is =DATE(2013,5,1)
cell I2 value is =DATE(2013,6,1)
cell J2 value is =DATE(2013,7,1)
cell K2 value is =DATE(2013,8,1)
cell L2 value is =DATE(2013,9,1)
cell M2 value is =DATE(2013,10,1)
cell N2 value is =DATE(2013,11,1)
cell O2 value is =DATE(2013,12,1)
Thanks
Try this:
UPDATE:
If you want the date values to be a formula, so that the dates change if the user changes the year, change the line inside the
For Loopto be: