Bonjour ,
Je débute en VBA et j'aimerai corriger l'erreur de l'espace pile insuffisant. Mon but était d'afficher une MessagBox lorsque le nombre de chiffres est différent de 14 pour la colonne G (c'est le dernier paragraphe) , or quand le nombre de chiffres est différent de 14 cela m'affiche le message ci-dessous. Il arrive parfois que Excel plante...
Voici mon code:
Merci d'avance pour votre aide !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 Private Sub CommandButton1_Click() End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then If Len(Target) > 10 Then Target.Value = Left(Target.Value, 10) End If End If If Not Application.Intersect(Target, Range("B:B")) Is Nothing Then If Len(Target) > 25 Then Target.Value = Left(Target.Value, 25) End If End If If Not Application.Intersect(Target, Range("D:D")) Is Nothing Then If Len(Target) > 70 Then Target.Value = Left(Target.Value, 70) End If End If If Not Application.Intersect(Target, Range("F:F")) Is Nothing Then If Len(Target) > 50 Then Target.Value = Left(Target.Value, 50) End If End If If Not Application.Intersect(Target, Range("G:G")) Is Nothing Then If Len(Target) <> 14 Then Target.Value = Replace(Target, "-", "") MsgBox "Le numéro doit contenir 14 chiffres !" End If If Not IsNumeric(Target) Then MsgBox "Veuillez entrer des chiffres uniquement" End If End If End Sub![]()
Partager