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
| Sub utilisegraphique()
'Je réalise mes graphes
Call Graphique(time_Range, pression_Range, "Pression en fonction du temps", "Temps [s]", "Pression [bar]", "Pression")
Call Graphique(time_Range, temperature_Range, "Temperature en fonction du temps", "Temps [s]", "Temperature [°C]", "Temperature")
End Sub
Sub Graphique(a As Range, b As Range, Titre As String, LegendeX As String, LegendeY As String, Nom As String)
Dim DerLig As Long
Dim LaCol As Byte
DerLig = Sheets("Feuil").Cells(Columns(1).Cells.Count, 1).End(xlUp).Row
If Nom = "Pression" Then 'Choisi la colonne pour la source de données en fonction du nom du graphique
LaCol = 3
Else
LaCol = 2
End If
Set XAdr = Sheets("Feuil").Range(Cells(2, 1), Cells(DerLig, 1))
Set YAdr = Sheets("feuil").Range(Cells(2, LaCol), Cells(DerLig, LaCol))
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = XAdr
ActiveChart.SeriesCollection(1).Values = YAdr
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:=Nom
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = Titre
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = LegendeX
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = LegendeY
End With
Sheets("Feuil").Select
End Sub |