apres vu comment j'ai conçu le moteur au départ
on simplifie encore plus
bref il a ce qu'il fautCode:
1
2
3
4
5
6
7
8
9
10
11
12
13 Private Sub Worksheet_Change(ByVal Target As Range) Dim formatage$, chaine$, Fx# If Target.Column = 1 And Target.Count = 1 Then chaine = Replace(Target.Value, " ", "") 'on cherche pas a comprendre on replace automatiquement la chaine If Len(chaine) Mod 2 <> 0 And chaine <> "" Then 'si c 'est impair et pas vide Fx = (Len(chaine) / 2) - 1 'pour obtenir le nombre de tranches -1 parce que on vire la derniere car elle est de 3 formatage = Application.Rept("@@ ", Round(Fx)) & "@@@" 'creation du pattern(modele de formatage Target.Value = Trim(Format(chaine, formatage)) 'application du formatage Else MsgBox "Nombres de caractères/chiffres incorrects": Application.Goto Target: Exit Sub End If End If End Sub
et comme je suis d'humeur decoupeuse j'en enleve un peu plus
:ptdr::ptdr:Code:
1
2
3
4
5
6
7
8
9
10
11 Private Sub Worksheet_Change(ByVal Target As Range) Dim chaine$ If Target.Column = 1 And Target.Count = 1 Then chaine = Replace(Target.Value, " ", "") 'on cherchje pas a comprendre on replace automatiquement la chaine If Len(chaine) Mod 2 <> 0 And chaine <> "" Then 'si c 'est impair et pas vide Target.Value = Trim(Format(chaine, Application.Rept("@@ ", 30) & "@@@")) 'application du formatage Else MsgBox "Nombres de caractères/chiffres incorrects": Application.Goto Target: Exit Sub End If End If End Sub