Excel - Macro copy Date for "n" month

Solved/Closed
mama_tracy Posts 3 Registration date Friday 14 May 2010 Status Member Last seen 18 May 2010 - 16 May 2010 à 22:48
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 18 May 2010 à 02:41
Hello,

Would you please help me to create a macro for generate Date schedule to Sheet2

It just like an installment schedule.


Sheet1
Col A is the detail of the installment, the value will not change by the amount of Col B
Col B is the terms of installment, so it will be the copy times of the rows
Col C is the start date of the installment. So copy to sheet2, the 1st row will be the Date value from Sheet1. But if sheet1 Col B = 2 and Col C = 01/09/2008, sheet2 B1 will show 01/09/2008 and B2 01/10/2008.


Let's see the example:


Sheet1

(Name) (Month) (Date:DD/MM/YYYY)
Col A Col B Col C
1 AAA 2 01/09/2008
2 BBB 5 01/01/2010


Sheet2

(Name) (Date:DD/MM/YYYY)
Col A Col B
1 AAA 01/09/2008
2 AAA 01/10/2008
3 BBB 01/01/2010
4 BBB 01/02/2010
5 BBB 01/03/2010
6 BBB 01/04/2010
7 BBB 01/05/2010


Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
17 May 2010 à 05:56
mama_tracy Posts 3 Registration date Friday 14 May 2010 Status Member Last seen 18 May 2010
18 May 2010 à 00:47
I know my two requests are very very similar. But can you teach me how to change the month in VBA? I only know the formula for change the month in excel =DATE(YEAR(B1),MONTH(B1)+1,DAY(B1)).
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
18 May 2010 à 02:41
There are more than one way you can do it. one way would be that before you start the macro, you convert it to the date. In fact if you use excel macro recorder and do it once, it will create a macro for you and then you can call that macro.

Other way would be to use CDATE

an other way would be to use formula

with range("C1:C19")

,formulaR1C1 = "=DATE(YEAR(RC2),MONTH(RC2)+1, DAY(RC2))

end with