Hi fantastic members,
I have created a monstrous calculator for work within my organisation. I have a user inoput screen to get a start and end date so I am pulling variables from there.
What i need is to be able to populate cells starting at A12:B12 with the start date in cell A12, then adding one month and getting that to populate into cell B12.
I need this to continue subsequently until the end date is reached. Managed to find this code which starts and stops on the dates I want but it populates days and only in column A.
Any help would be much appreciated. Just to clarify I would be looking at something like this:
A12 shows "06/10/10"
B12 shows "05/11/10"
A13 shows "06/11/10"
B13 shows "05/12/10" etc etc until the end date is reached
I have created a monstrous calculator for work within my organisation. I have a user inoput screen to get a start and end date so I am pulling variables from there.
What i need is to be able to populate cells starting at A12:B12 with the start date in cell A12, then adding one month and getting that to populate into cell B12.
I need this to continue subsequently until the end date is reached. Managed to find this code which starts and stops on the dates I want but it populates days and only in column A.
Any help would be much appreciated. Just to clarify I would be looking at something like this:
A12 shows "06/10/10"
B12 shows "05/11/10"
A13 shows "06/11/10"
B13 shows "05/12/10" etc etc until the end date is reached
Code:
Private Sub CommandButton21_Click()
Dim startdate As Date
Dim enddate As Date
Dim row As Double
startdate = Range("D9").Value
enddate = Range("D10").Value
row = 0
With Worksheets("Sheet1")
Range("A12:B12").Select
Do Until DateAdd("d", 1, startdate) = enddate + 1
ActiveCell.Offset(row, 0).Value = DateAdd("d", 1, startdate)
startdate = startdate + 1
row = row + 1
Loop
End With
End Sub
Comment