bonsoir

j ai un probleme je voudrais si les cellules de af18 a af25 contient #div/0! apparait un message d erreur.
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
Sub testmfc1()
 '
 
 ''''''
 
 'si dans la colonne AF18 a AF22 est inscrit #div/0!
 'alors afficher message sinon continuer le code
 
 Dim g As Byte
 
For g = 18 To 22
If IsEmpty(Range("af" & g)) Then
    MsgBox "générer une attribution avant de colorier!"
    Cancel = True
 
    Exit Sub
End If
Next g
 
 '''''''''''''
 '''''''''''
 
 x = Sheets.Count
n = 18
For i = 1 To x
 
    While Cells(n, 29) <> ""
        If Cells(n, 29) > Cells(n, 32) Then
        Cells(n, 32).Interior.ColorIndex = 44 'orange
        ElseIf Cells(n, 29) < Cells(n, 32) Then
        Cells(n, 32).Interior.ColorIndex = 3 'rouge
        ElseIf Cells(n, 29) = Cells(n, 32) Then
        Cells(n, 32).Interior.ColorIndex = 43 ' ou 45 'vert
        End If
        n = n + 1
    Wend
    n = 18
Next i
 
 Range("af18").Activate
 
End Sub
merci