Hi guys,
I'm trying to write some code to output a set of payment dates starting from a set start date. Term is the number of years the payment schedule goes on for and the frequency is the number of payments a year. Whenever I run this code 00:00:00 get outputted as the first date Any ideas why this happens? Thanks
I'm trying to write some code to output a set of payment dates starting from a set start date. Term is the number of years the payment schedule goes on for and the frequency is the number of payments a year. Whenever I run this code 00:00:00 get outputted as the first date Any ideas why this happens? Thanks
Book1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | |||||
2 | |||||
3 | |||||
4 | 0:00:00 | D0_ | 1/1/22 | ||
5 | 1/6/22 | ||||
6 | 1/12/22 | Term | 20 | ||
7 | 1/6/23 | Frequency | 2 | ||
8 | 1/12/23 | ||||
9 | 31/05/2024 | ||||
10 | 29/11/2024 | ||||
11 | 30/05/2025 | ||||
12 | 1/12/25 | ||||
13 | 1/6/26 | ||||
14 | 1/12/26 | ||||
15 | 1/6/27 | ||||
16 | 1/12/27 | ||||
17 | 1/6/28 | ||||
18 | 1/12/28 | ||||
19 | 1/6/29 | ||||
20 | 30/11/2029 | ||||
21 | 31/05/2030 | ||||
22 | 29/11/2030 | ||||
23 | 30/05/2031 | ||||
24 | 1/12/31 | ||||
25 | 1/6/32 | ||||
26 | 1/12/32 | ||||
27 | 1/6/33 | ||||
28 | 1/12/33 | ||||
29 | 1/6/34 | ||||
30 | 1/12/34 | ||||
31 | 1/6/35 | ||||
32 | 30/11/2035 | ||||
33 | 30/05/2036 | ||||
34 | 1/12/36 | ||||
35 | 1/6/37 | ||||
36 | 1/12/37 | ||||
37 | 1/6/38 | ||||
38 | 1/12/38 | ||||
39 | 1/6/39 | ||||
40 | 1/12/39 | ||||
41 | 1/6/40 | ||||
42 | 30/11/2040 | ||||
Sheet1 |
VBA Code:
Sub dates()
Dim dv() As Date
Dim i As Integer
Dim n As Integer
Dim D0_ As Date
D0_ = Range("C4")
n = Range("C6") * Range("C7")
ReDim dv(0 To n) As Date
With WorksheetFunction
For i = 1 To n
dv(i) = CDate(.WorkDay(D0_, .NetworkDays(D0_, .EDate(D0_, Round(i * 12 / Range("C7")) - 1))))
Next i
End With
Range("A4:A" & UBound(dv) + 2) = Application.Transpose(dv)