1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Dim texte As String
Dim col As Range
Set col = Range("C:C")
Set cell = Target
'sortie...
If Left(cell.Text, 2) = "FR" Or _
cell.Column <> col.Column Or _
cell.Text = "" _
Then Exit Sub 'pour eviter le bouclage
'format...
If Len(cell.Text) = 25 Then
texte = Left(cell.Text, 25)
texte = "FR" + texte
i = 4
Do
texte = Left(texte, i) + " " + Right(texte, Len(texte) - i)
i = i + 5
Loop Until i >= 30
Target.Value = texte
Else
'erreur de saisie ... (25 chiffres!)
Target.Value = "FR erreur de saisie"
End If
End Sub |
Partager