指定した年、月、日から日付型を取得する
DateSerial関数を使うと、指定した年、月、日を日付型で取得できます。
実行プログラム
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Sub Sample8_6_1() Dim intY As Integer Dim intM As Integer Dim intD As Integer intY = Cells(1, 2).Value intM = Cells(2, 2).Value intD = Cells(3, 2).Value Debug.Print DateSerial(intY, intM, intD) Debug.Print DateSerial(intY, intM, intD) + 1 End Sub |
実行条件
![](http://excelmemo.com/wp-content/uploads/PIC080601.jpg)
実行結果
![](http://excelmemo.com/wp-content/uploads/PIC080602.jpg)
指定した時、分、秒から日付型を取得する
TimeSerial関数を使うと、指定した時、分、秒を日付型で取得できます。
実行プログラム
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Sub Sample8_6_2() Dim intH As Integer Dim intM As Integer Dim intS As Integer intH = Cells(1, 2).Value intM = Cells(2, 2).Value intS = Cells(3, 2).Value Debug.Print TimeSerial(intH, intM, intS) Debug.Print TimeSerial(intH, intM, intS + 1) End Sub |
実行条件
![](http://excelmemo.com/wp-content/uploads/PIC080603.jpg)
実行結果
![](http://excelmemo.com/wp-content/uploads/PIC080604.jpg)