Bonjour à tous,
J'ai écris une macro qui permet de détecter si une valeur n'est pas entière, et, le cas échéant, de la modifier. Cependant, lorsque les valeurs ont plus de 4 chiffres, j'ai le message suivant :Voici mon code :Erreur d'exécution 6 Dépassement de capacité.
Si je fais le même exercice, mais en recherchant les valeurs négatives, cela fonctionne parfaitement, quelque soit la grandeur de a valeur.
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
47
48
49
50
51
52
53
54
55
56
57 Sub TesterNbreEntier() 'Variables Dim Cell As Object Dim ValCell As Variant Dim CellTot As Long Dim CellTotBlank As Double Dim CellNeg As Long 'Initiate ActiveCell.Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select CellTotBlank = WorksheetFunction.CountBlank(Selection) CellTot = WorksheetFunction.CountA(Selection) CellNeg = 0 'Processing If CellTotBlank >= CellTot Then ActiveCell.Select MsgBox "Vous avez sélectionné une cellule en dehors du tableau.", vbOKOnly + vbExclamation, "Message Important" Exit Sub End If For Each Cell In Selection If Not IsNumeric(Cell) Then Cell = Cell ElseIf Cell <> CInt(Cell) Then CellNeg = CellNeg + 1 With Cell .Select .Font.Bold = True .Interior.ColorIndex = 8 .Font.Italic = True End With Do While Cell <> CInt(Cell) Or Cell = "" ValCell = InputBox("Introduire la valeur cellule") Cell = ValCell Cell.Activate Loop With Cell .Font.Bold = False .Interior.ColorIndex = 0 .Font.Italic = False End With End If Next Cell 'Closing ActiveCell.Select MsgBox "Il y avait " & CellNeg & " valeur(s) avec décimale(s) !!", vbOKOnly + vbInformation, "Information" End Sub
Quelqu'un a-t-il une idée de ce qui se passe ?
Merci
Partager