回答編集履歴
2
コード追記
test
CHANGED
@@ -43,3 +43,49 @@
|
|
43
43
|
|
44
44
|
|
45
45
|
Date型も中身は数値型(倍精度浮動小数点型)なのでForでループできます。
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
---
|
50
|
+
|
51
|
+
ループを使わずにやる方法も。
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
```vba
|
56
|
+
|
57
|
+
Public Sub template1()
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Dim dateStartDate As Date '開始日
|
62
|
+
|
63
|
+
Dim dateEndDate As Date '終了日
|
64
|
+
|
65
|
+
Dim loncntDay As Long
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
dateStartDate = wsDateList.Range("D2")
|
70
|
+
|
71
|
+
dateEndDate = wsDateList.Range("E2")
|
72
|
+
|
73
|
+
loncntDay = DateDiff("d", dateStartDate, dateEndDate)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
wsTemplate2.Range("E2").Value = dateStartDate
|
78
|
+
|
79
|
+
With wsTemplate2.Range("F2").Resize(, loncntDay)
|
80
|
+
|
81
|
+
.Formula = "=E2+1" '左のセルに+1
|
82
|
+
|
83
|
+
.Value = .Value '式を値に変換
|
84
|
+
|
85
|
+
End With
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
End Sub
|
90
|
+
|
91
|
+
```
|
1
コード修正
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
|
27
|
+
Dim Dayone As Date
|
28
28
|
|
29
29
|
For Dayone = dateStartDate To dateEndDate '開始日から終了日までループ
|
30
30
|
|
@@ -39,3 +39,7 @@
|
|
39
39
|
End Sub
|
40
40
|
|
41
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
Date型も中身は数値型(倍精度浮動小数点型)なのでForでループできます。
|