OVH Cloud OVH Cloud

Mise en forme conditionnelle d'un Graphique

2 réponses
Avatar
If
Bonsoir à tous

En prenant l'idée que je peux trouver ici :
http://forum.telecharger.01net.com/microhebdo/logiciels/bureautique/couleur_graphique_excel-327499/messages-1.html

J'aimerais obtenir un graphique avec des barres colorisées avec condition.
Par exemple, si la valeur est supérieure à 60% la barre serait rouge.

CA Un Deux Trois Quatre Cinq
Jan. 45% 88% 60% 40% 50%
Fév. 40% 44% 10% 44% 44%
Mar. 28% 77% 44% 79% 40%
Avr. 37% 44% 55% 44% 44%

Fichier exemple : http://cjoint.com/?fzxFgRiqFR


Procédure se trouvant sur la page renseignée ci-dessus.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B5:C8"), Target) Is Nothing Then
Dim I As Integer
With ChartObjects(1).Chart.SeriesCollection(1)
For I = 1 To .Points.Count
If Cells(I + 4, 2) < Cells(I + 4, 3) Then
.Points(I).Interior.Color = vbRed
Else
.Points(I).Interior.Color = vbGreen
End If
Next
End With
End If
End Sub



En avance merci pour vos tuyaux.


Yves

2 réponses

Avatar
lSteph
Bonsoir,
Pour adapter il faut distinguer graphique séries en lignes (ton exemple)ou
en colonnes(celui de01):

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B2:f5"), Target) Is Nothing Then
Dim I As Integer, J as Integer

With ChartObjects(1).Chart
For j = 1 To .SeriesCollection.Count
For I = 1 To .SeriesCollection(j).Points.Count
If Cells(j + 1, I + 1) > 0.6 Then
.SeriesCollection(j).Points(I).Interior.Color = vbRed
Else
.SeriesCollection(j).Points(I).Interior.Color = vbGreen
End If
Next
Next
End With
End If
End Sub


'lSteph
"If" a écrit dans le message de news:
447622da$0$23248$
Bonsoir à tous

En prenant l'idée que je peux trouver ici :
http://forum.telecharger.01net.com/microhebdo/logiciels/bureautique/couleur_graphique_excel-327499/messages-1.html

J'aimerais obtenir un graphique avec des barres colorisées avec condition.
Par exemple, si la valeur est supérieure à 60% la barre serait rouge.

CA Un Deux Trois Quatre Cinq
Jan. 45% 88% 60% 40% 50%
Fév. 40% 44% 10% 44% 44%
Mar. 28% 77% 44% 79% 40%
Avr. 37% 44% 55% 44% 44%

Fichier exemple : http://cjoint.com/?fzxFgRiqFR


Procédure se trouvant sur la page renseignée ci-dessus.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B5:C8"), Target) Is Nothing Then
Dim I As Integer
With ChartObjects(1).Chart.SeriesCollection(1)
For I = 1 To .Points.Count
If Cells(I + 4, 2) < Cells(I + 4, 3) Then
.Points(I).Interior.Color = vbRed
Else
.Points(I).Interior.Color = vbGreen
End If
Next
End With
End If
End Sub



En avance merci pour vos tuyaux.


Yves


Avatar
If
Merci pour ta grande aide !!

Yves


----- Original Message -----
From lSteph
, Sent 26/05/2006 0:10:
Bonsoir,
Pour adapter il faut distinguer graphique séries en lignes (ton exemple)ou
en colonnes(celui de01):

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B2:f5"), Target) Is Nothing Then
Dim I As Integer, J as Integer

With ChartObjects(1).Chart
For j = 1 To .SeriesCollection.Count
For I = 1 To .SeriesCollection(j).Points.Count
If Cells(j + 1, I + 1) > 0.6 Then
.SeriesCollection(j).Points(I).Interior.Color = vbRed
Else
.SeriesCollection(j).Points(I).Interior.Color = vbGreen
End If
Next
Next
End With
End If
End Sub


'lSteph
"If" a écrit dans le message de news:
447622da$0$23248$
Bonsoir à tous

En prenant l'idée que je peux trouver ici :
http://forum.telecharger.01net.com/microhebdo/logiciels/bureautique/couleur_graphique_excel-327499/messages-1.html

J'aimerais obtenir un graphique avec des barres colorisées avec condition.
Par exemple, si la valeur est supérieure à 60% la barre serait rouge.

CA Un Deux Trois Quatre Cinq
Jan. 45% 88% 60% 40% 50%
Fév. 40% 44% 10% 44% 44%
Mar. 28% 77% 44% 79% 40%
Avr. 37% 44% 55% 44% 44%

Fichier exemple : http://cjoint.com/?fzxFgRiqFR


Procédure se trouvant sur la page renseignée ci-dessus.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B5:C8"), Target) Is Nothing Then
Dim I As Integer
With ChartObjects(1).Chart.SeriesCollection(1)
For I = 1 To .Points.Count
If Cells(I + 4, 2) < Cells(I + 4, 3) Then
.Points(I).Interior.Color = vbRed
Else
.Points(I).Interior.Color = vbGreen
End If
Next
End With
End If
End Sub



En avance merci pour vos tuyaux.


Yves