Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
If Target.Column = 3 Or Target.Column = 7 Then '3表示3列、7表示7列
If Target.Value <= 24 Then
If Target.Value > 12 Then
Target.NumberFormatLocal = Application.Substitute(Target.Value - 12, "0", "!0") & ""
Else
Target.NumberFormatLocal = "G/通用格式" '12以下 都是显示常规
End If
End If
End If
End If
End Sub