Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 10/11/2011, 18h34   #1
Invité de passage
 
Inscription : mars 2010
Messages : 39
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 39
Points : 3
Points : 3
Par défaut Problème Code avec If

Bonjour,
J'ai réalisé le code suivant, et je ne comprends pas pourquoi quand je lance ma macro Excel me met "Erreur de compilation : Else sans If"...

D'où vient ce problème ? Merci par avance pour vos réponses !


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
For i = 3 To 39
For j = 2 To 19
 
If Cells(i, j).Value > 1200 Then Cells(i, j).Font.Color = RGB(90, 13, 38)
    ElseIf Cells(i, j).Value > 1100 Then Cells(i, j).Font.Color = RGB(112, 13, 38)
    ElseIf Cells(i, j).Value > 1000 Then Cells(i, j).Font.Color = RGB(176, 13, 38)
    ElseIf Cells(i, j).Value > 900 Then Cells(i, j).Font.Color = RGB(250, 13, 38)
    ElseIf Cells(i, j).Value > 800 Then Cells(i, j).Font.Color = RGB(250, 46, 38)
    ElseIf Cells(i, j).Value > 700 Then Cells(i, j).Font.Color = RGB(250, 96, 38)
    ElseIf Cells(i, j).Value > 600 Then Cells(i, j).Font.Color = RGB(250, 155, 38)
    ElseIf Cells(i, j).Value > 500 Then Cells(i, j).Font.Color = RGB(250, 252, 38)
    ElseIf Cells(i, j).Value > 400 Then Cells(i, j).Font.Color = RGB(250, 252, 109)
    ElseIf Cells(i, j).Value > 300 Then Cells(i, j).Font.Color = RGB(250, 252, 238)
    ElseIf Cells(i, j).Value > 200 Then Cells(i, j).Font.Color = RGB(13, 240, 190)
    ElseIf Cells(i, j).Value > 200 Then Cells(i, j).Font.Color = RGB(13, 117, 190)
    ElseIf Cells(i, j).Value > 100 Then Cells(i, j).Font.Color = RGB(13, 5, 190)
    ElseIf Cells(i, j).Value > 50 Then Cells(i, j).Font.Color = RGB(13, 5, 94)
    ElseIf Cells(i, j).Value > 15 Then Cells(i, j).Font.Color = RGB(13, 5, 4)
End If
 
Next j
Next i
Sylv3D est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/11/2011, 18h41   #2
Expert Confirmé Sénior
 
Avatar de mercatog
 
Inscription : juillet 2008
Messages : 5 848
Détails du profil
Informations forums :
Inscription : juillet 2008
Messages : 5 848
Points : 13 907
Points : 13 907
Pas sur la même ligne
Indente ton code pour la lisibilité

Code :
1
2
3
4
5
6
7
8
9
10
11
12
Dim i As Integer, j As Integer
 
For i = 3 To 39
    For j = 2 To 19
        If Cells(i, j).Value > 1200 Then
            Cells(i, j).Font.Color = RGB(90, 13, 38)
        ElseIf Cells(i, j).Value > 1100 Then
            Cells(i, j).Font.Color = RGB(112, 13, 38)
 '....
        End If
    Next j
Next i
__________________
Cordialement.
mercatog est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/11/2011, 18h54   #3
Invité de passage
 
Inscription : mars 2010
Messages : 39
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 39
Points : 3
Points : 3
Merci bien !
Sylv3D est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 06h39.


 
 
 
 
Partenaires

Hébergement Web