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
|
Sub Courbe()
Dim FSGraph As Chart, Graphik As Worksheet, Donnees As Range
Dim PlageX As Range, PlageY As Range, MaSerie As Series, cmpt As Long
Set Graphik = Worksheets("Graphikgrundlag. techn. Fortsch")
' # Boucle pour transformer les date en texte
For Each PlageX In Graphik.Range(Graphik.Cells(6, 3), Graphik.Cells(6, Graphik.Cells(6, 3).End(xlToRight).Column))
PlageX = "'" & Format(PlageX.Value, "mmm-yy")
Next
With Graphik
Set Donnees = .Range(.Cells(6, 3), .Cells(9, .Cells(6, 3).End(xlToRight).Column))
End With
Set FSGraph = ThisWorkbook.Charts.Add
FSGraph.ChartArea.Clear
FSGraph.ChartType = xlXYScatter
Set PlageX = Donnees.Rows(1)
For cmpt = 1 To Donnees.Rows.Count - 1
Set PlageY = PlageX.Offset(cmpt, 0)
Set MaSerie = FSGraph.SeriesCollection.NewSeries
With MaSerie
.Values = PlageY
.XValues = PlageX
End With
FSGraph.SeriesCollection(cmpt).Name = "=""" & Graphik.Range(Donnees.Cells(cmpt + 1, 0).Address).Value & """"
Next cmpt
FSGraph.SeriesCollection(1).ChartType = xlColumnClustered
FSGraph.Location Where:=xlLocationAsObject, Name:="Graph"
' # Boucle pour remettre les dates
For Each PlageX In Graphik.Range(Graphik.Cells(6, 3), Graphik.Cells(6, Graphik.Cells(6, 3).End(xlToRight).Column))
PlageX = Replace(PlageX.Value, "'", "")
Next
End Sub |
Partager