Og lige en sidste, der kun gir boks, ved problemer:
Sub Dato_ændring_Advarsel()
'
' Genvejstast: Ctrl+Skift+Q
'
For Each c In Selection.Cells
c.Select
År = Right(ActiveCell, 2)
If År <> "" Then
År = 20 & År
End If
Måned = Left(Right(ActiveCell, 4), 2)
If Len(ActiveCell.Formula) = 5 Then
Dag = 0 & Left(ActiveCell, 1)
End If
If Len(ActiveCell.Formula) = 6 Then
Dag = Left(ActiveCell, 2)
End If
If Måned > 12 Then GoTo Advarsel
If Dag > 31 Then GoTo Advarsel
If IsEmpty(ActiveCell) Then GoTo Advarsel
If Not IsNumeric(ActiveCell.Value) Then GoTo Advarsel
If IsError(ActiveCell.Value) Then GoTo Advarsel
If IsDate(ActiveCell.Value) Then GoTo Advarsel
If Len(ActiveCell.Formula) < 5 Then GoTo Advarsel
If Len(ActiveCell.Formula) > 6 Then GoTo Advarsel
GoTo Ændre
Advarsel:
Svar = MsgBox("Dag = " & vbTab & Dag & Bemærk2 & vbCrLf & _
"Måned = " & Måned & Bemærk1 & vbCrLf & _
"År = " & vbTab & År & vbCrLf & _
vbCrLf & _
"Vil du bruge: " & vbTab & Dag & "-" & Måned & "-" & År & vbCrLf & _
"Som dato i cellen?", vbYesNo, "Godkend")
If Svar = vbYes Then
Ændre:
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Value = Dag & "-" & Måned & "-" & År
År = Empty
Måned = Empty
Dag = Empty
ActiveCell.Offset(1, 0).Select
ElseIf Svar = vbNo Then
End If
Next c
End Sub