|
目的のセルを選択して、以下のマクロを実行してみて下さい。
Sub Chg_MyD_Format()
Dim CkSt As String
Dim Ary As Variant
Dim MyY As Integer, NewY As Integer
Dim RtDay As Date
CkSt = Left$(ActiveCell.Value, 2)
If CkSt <> "大正" And CkSt <> "昭和" _
And CkSt <> "平成" Then Exit Sub
Ary = Split(ActiveCell.Value, "/")
MyY = Val(Right(Ary(0), Len(Ary(0)) - 2))
Select Case CkSt
Case "大正": NewY = MyY + 1911
Case "昭和": NewY = MyY + 1925
Case "平成": NewY = MyY + 1988
End Select
RtDay = DateValue(NewY & "/" & Ary(1) & "/" & Ary(2))
ActiveCell.Value = Format(RtDay, "yyyy/mm/dd")
End Sub
|
|