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 58 59 60
| Dim Graph As Graph.Chart
Dim oDataS As Object
Dim noCourbe As Integer
Dim NomBarre, Mois As String
M3 = DLookup("Mois", "rqt-pour-graph-logistique-clt-cam-2")
VTMTD = DLookup("[" & M3 & "]", "Objectif", "[Champs-var] = 'CamTotal' And [LIGNE] ='MTD'")
VTYTD = DLookup("[" & M3 & "]", "Objectif", "[Champs-var] = 'CamTotal' And [LIGNE] = 'YTD'")
V1hMTD = DLookup("[" & M3 & "]", "Objectif", "[Champs-var] = 'Cam1h' And [LIGNE] ='MTD'")
V1hYTD = DLookup("[" & M3 & "]", "Objectif", "[Champs-var] = 'Cam1h' And [LIGNE] = 'YTD'")
Vp1hMTD = DLookup("[" & M3 & "]", "Objectif", "[Champs-var] = 'Cam+1h' And [LIGNE] ='MTD'")
Vp1hYTD = DLookup("[" & M3 & "]", "Objectif", "[Champs-var] = 'Cam+1h' And [LIGNE] = 'YTD'")
Set db = CurrentDb
Set Graph = Me.Graphique4.Object.Application.Chart
Set oDataS = Graph.Application.DataSheet
nbcourbe1 = Graph.SeriesCollection.Count
For noCourbe1 = 1 To nbcourbe1 + 1
NomBarre1 = oDataS.Cells(1, noCourbe1 + 1).Value
ValMTD = oDataS.Cells(2, noCourbe1 + 1).Value
ValYTD = oDataS.Cells(3, noCourbe1 + 1).Value
'On compte le nombre de points (Barre) du graphique
nbcourbe = Graph.SeriesCollection.Count
For noCourbe = 2 To nbcourbe + 1
NomBarre = oDataS.Cells(noCourbe, 1).Value
'ValBarre = oDataS.Cells(noCourbe, 2).Value
If NomBarre = "MTD" Then
If NomBarre1 = "Total" Then
MsgBox (NomBarre & "--" & NomBarre1 & "--" & ValMTD & "--" & VTMTD)
If ValMTD < VTMTD Then
With Graph.SeriesCollection(NomBarre)
.Interior.Color = RGB(255, 0, 0)
End With
ElseIf ValMTD > VTMTD Then
With Graph.SeriesCollection(NomBarre)
.Interior.Color = RGB(0, 255, 0)
End With
End If
ElseIf NomBarre1 = "Moins d'1h" Then
MsgBox (NomBarre & "--" & NomBarre1 & "--" & ValMTD & "--" & V1hMTD)
If ValMTD < V1hMTD Then
With Graph.SeriesCollection(NomBarre)
.Interior.Color = RGB(255, 0, 0)
End With
ElseIf ValMTD > V1hMTD Then
With Graph.SeriesCollection(NomBarre)
.Interior.Color = RGB(0, 255, 0)
End With
End If
End If
End If
Next
Next |
Partager