
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A5:A150")) Is Nothing Then Exit Sub
On Error Resume Next
Dim S_data As String
Target.NumberFormat = "General"
Application.EnableEvents = False
Select Case Len(Target.Value)
Case 4
S_data = "0" & Mid(Target.Value, 1, 1) & "0" & Mid(Target.Value, 2, 1) & "20" & _
Mid(Target.Value, 3, 2)
Case 5
S_data = "0" & Mid(Target.Value, 1, 3) & "20" & Mid(Target.Value, 4, 2)
Case 6
S_data = Mid(Target.Value, 1, 4) & "20" & Mid(Target.Value, 5, 2)
Case 8
S_data = Target.Value
Case Else
Cells(Target.Row, Target.Column) = "Dato Non valido"
Application.EnableEvents = True
Exit Sub
End Select
Target = DateSerial(Mid(S_data, 5, 4), Mid(S_data, 3, 2), Mid(S_data, 1, 2))
Application.EnableEvents = True
End Sub
|
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
Selection.NumberFormat = "ddmmyyyy"
End Sub |
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("A5:A150")) Is Nothing Then Exit Sub
Selection.NumberFormat = "ddmmyyyy"
End Sub |
'Codice Mister_x
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A5:A150")) Is Nothing Then Exit Sub
On Error Resume Next
Dim S_data As String
Target.NumberFormat = "General"
Application.EnableEvents = False
Select Case Len(Target.Value)
Case 4
S_data = "0" & Mid(Target.Value, 1, 1) & "0" & Mid(Target.Value, 2, 1) & "20" & _
Mid(Target.Value, 3, 2)
Case 5
S_data = "0" & Mid(Target.Value, 1, 3) & "20" & Mid(Target.Value, 4, 2)
Case 6
S_data = Mid(Target.Value, 1, 4) & "20" & Mid(Target.Value, 5, 2)
Case 8
S_data = Target.Value
Case Else
Cells(Target.Row, Target.Column) = "Dato Non valido"
Application.EnableEvents = True
Exit Sub
End Select
Target = DateSerial(Mid(S_data, 5, 4), Mid(S_data, 3, 2), Mid(S_data, 1, 2))
Application.EnableEvents = True
End Sub
'Codice Michelangelo
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("A5:A150")) Is Nothing Then Exit Sub
Selection.NumberFormat = "ddmmyyyy"
End Sub
|
