Bonjour la compagnie
@ atlas & curulis
Bonjour curilis57 et merci.
Seulement, je voulais formater les cellules avec :
Target.NumberFormat = "@"
Mais ça ne marche pas !
le problème étant le formatage automatique en date, tu peux très bien reprendre la proposition de curulis et si target est détecté en date, remettre sa forme initiale, formater en @
If IsDate(Target) Then x = Day(Target) & "-" & Month(Target)
et ensuite traiter simplement comme curulis le proposait
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If IsDate(Target) Then x = Day(Target) & "-" & Month(Target)
Target.NumberFormat = "@"
If InStr(x, "-") > 0 Then
If InStrRev(x, "-") = InStr(x, "-") Then
If IsNumeric(Split(x, "-")(0)) And IsNumeric(Split(x, "-")(1)) Then
Target = "F" & Format(Split(x, "-")(0), "0") & "-" & "F" & Format(Split(x, "-")(1), "0")
Target.Characters(2, InStr(Target, "-") - 2).Font.Subscript = True
Target.Characters(InStr(Target, "-") + 2, Len(Target) - InStr(Target, "-") - 1).Font.Subscript = True
End If
End If
End If
Application.EnableEvents = True
End Sub
cela fonctionne très bien avec deux fois un simple chiffre, je n'ai pas été plus loin
dans cette version, seule la cellule touché est en format @
je ne dis pas que les autres propositions ne sont pas valables, je dis seulement que le format n'était pas incompatible de la proposition, de curulis