1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub CommandButton1_Click()
Dim retour As VbMsgBoxResult, FORMAT_US_FR As String, x As Long
retour = vbYes
x = Application.International(xlDateOrder)
FORMAT_US_FR = Switch(x = 0, "mm/dd/yyyy", x = 1, "dd/mm/yyyy", x = 2, "yyyy/mm/dd")
With TextBox1
If IsDate(.Value) Then
If Format(.Value, FORMAT_US_FR) <> .Value Then
retour = MsgBox("la date est valide mais pas au bon format" & vbCrLf & "voulez vous la mettre reformatée", vbYesNo, "conversion de date")
End If
If retour = vbYes Then Sheets("feuil1").Cells(1, 2) = Replace(DateSerial(Year(.Value), Month(.Value), Day(.Value)), "/", "-")
Else
MsgBox "ca n'est pas une date valide !!"
End If
End With
End Sub
Private Sub CommandButton2_Click()
TextBox1 = Replace(Sheets(1).Range("A1").Text, "-", "/")
End Sub |
Partager