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
| Sub Graphique()
Dim DerLig As Long, DerCol As Long
Dim Valeur_Min As Double, Valeur_Max As Double
Application.ScreenUpdating = False
Sheets("Feuil1").Select
Range("C1") = ""
Range("C1", Range("A1").End(xlDown).End(xlToRight)).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.Location Where:=xlLocationAsNewSheet
'Ajout de la série "Temps"
DerLig = Sheets("Feuil1").Range("A1").End(xlDown).Row
DerCol = Sheets("Feuil1").Range("A1").End(xlToRight).Column
Sheets("Feuil1").Range("C1") = "Temps"
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(22).Name = "=""Temps"""
ActiveChart.SeriesCollection(22).Values = "=Feuil1!C2:C" & Sheets("Feuil1").Range("A1").End(xlDown).Row
'Réduction des axes pour une meilleure lisibilité (facultatif)
Valeur_Min = Application.Min(Sheets("Feuil1").Cells(2, "D"), Sheets("Feuil1").Cells(DerLig, DerCol))
Valeur_Max = Application.Max(Sheets("Feuil1").Cells(2, "D"), Sheets("Feuil1").Cells(DerLig, DerCol))
ActiveChart.Axes(xlValue).MinimumScale = Round(Valeur_Min - 15, 0)
ActiveChart.Axes(xlValue).MaximumScale = Round(Valeur_Max + 15, 0)
End Sub |
Partager