OVH Cloud OVH Cloud

petit problème

3 réponses
Avatar
eric
Bonjour,
J'ai le code suivant :
Sheets("Feuil1").Select
For Each Cell In Range("C2:C65")
If Cell.Value < "100%" Then
Cell.Select
With Selection.Interior
.ColorIndex =3D 48
.Pattern =3D xlSolid
End With
End If
If Cell.Value >=3D "100%" And Cell.Value < "141%" Then
Cell.Select
With Selection.Interior
.ColorIndex =3D 15
.Pattern =3D xlSolid
End With
End If
Next
End Sub
Quand j'ex=E9cute, toutes mes cellules sont en couleur 48. Quand je fais
F8, je constate que je ne rentre jamais dans : If Cell.Value >=3D "100%"
And Cell.Value < "141%" Then
Mes cellules =E9taient au format standard, j'ai chang=E9 enb format
pourcentage, mais toujours le m=EAme r=E9sultat...
Une explication ?
Merci d'avance
Eric

3 réponses

Avatar
Youky
Remplace "100%" par 1
et "141%" par 1,41 sans les guillemets.
Youky
"eric" a écrit dans le message de news:

Bonjour,
J'ai le code suivant :
Sheets("Feuil1").Select
For Each Cell In Range("C2:C65")
If Cell.Value < "100%" Then
Cell.Select
With Selection.Interior
.ColorIndex = 48
.Pattern = xlSolid
End With
End If
If Cell.Value >= "100%" And Cell.Value < "141%" Then
Cell.Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If
Next
End Sub
Quand j'exécute, toutes mes cellules sont en couleur 48. Quand je fais
F8, je constate que je ne rentre jamais dans : If Cell.Value >= "100%"
And Cell.Value < "141%" Then
Mes cellules étaient au format standard, j'ai changé enb format
pourcentage, mais toujours le même résultat...
Une explication ?
Merci d'avance
Eric
Avatar
Jacky
Bonsoir,

Avec les cellules au format %
Ceci:
'--------
Sub jj()
Sheets("Feuil1").Select
For Each cell In Range("C2:C65")
If cell.Value < 1 Then cell.Interior.ColorIndex = 48
If cell.Value >= 1 And cell.Value < 1.41 Then cell.Interior.ColorIndex 15
Next
End Sub
'----------
Salutations
JJ


"eric" a écrit dans le message de
news:
Bonjour,
J'ai le code suivant :
Sheets("Feuil1").Select
For Each Cell In Range("C2:C65")
If Cell.Value < "100%" Then
Cell.Select
With Selection.Interior
.ColorIndex = 48
.Pattern = xlSolid
End With
End If
If Cell.Value >= "100%" And Cell.Value < "141%" Then
Cell.Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If
Next
End Sub
Quand j'exécute, toutes mes cellules sont en couleur 48. Quand je fais
F8, je constate que je ne rentre jamais dans : If Cell.Value >= "100%"
And Cell.Value < "141%" Then
Mes cellules étaient au format standard, j'ai changé enb format
pourcentage, mais toujours le même résultat...
Une explication ?
Merci d'avance
Eric
Avatar
eric
Merci
Ca ne marche pas avec 1,41 ça marche avec 1.41