VBA 年の下二けたを表示させる Format
VBA(version7.1)で年の下二けたを表示させたいと思っています。
Format関数では両者とも5,
date関数はyear関数を使うと1905と表示
right関数を使うと20と意図通り表示します。
このような結果になるのはなぜでしょうか。
詳しい方よろしくお願いします。
Sub test()
Cells(1, 1) = Format(Year(Date), "yy")
Cells(2, 1) = Format(Year(Now), "yy")
Cells(1, 2) = Right(Year(Date), 2)
Cells(2, 2) = Right(Year(Now), 2)
Cells(1, 3) = Year(Date)
Cells(2, 3) = Year(Now)
End Sub
実行結果
5_20_1905/7/12
5_20_2020
お礼
ありがとうございます