|
▼kazu さん:
こんばんは。
Private Sub Worksheet_Change(ByVal Target As Range)
Const addr = "$a$1"
Dim rng As Range
With Application
.EnableEvents = False
Set rng = .Intersect(Range(addr), Target)
If Not rng Is Nothing Then
With Target
.NumberFormatLocal = "標準"
If Val(.Value) >= 1 And Val(.Value) <= 12 Then
.Value = DateSerial(IIf(Month(Date) = 12 _
And Val(.Value) <> 12, _
Year(Date) + 1, Year(Date)), Val(.Value), 1)
.NumberFormatLocal = "m""月""d""日"""
Else
MsgBox "nogood"
End If
End With
End If
.EnableEvents = True
Set rng = Nothing
End With
End Sub
でためしてみてください。
でも、これだと今年と来年1月1日の区別が付かなくなりますけどね!!
|
|