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
| Sub selection()
Dim ncol1, ncol2, ncol3, ncol4
Dim Graph As Chart, Ligne As Long, Nom As String, Graph1 As ChartObject
Dim Plage1 As Range, Plage2 As Range, Plage3 As Range, Plage4 As Range
Nom = ActiveSheet.Name
ncol1 = ActiveCell.Column
ncol2 = ncol1 + 1
ncol3 = ncol1 + 2
ncol4 = ncol1 + 6
Ligne = Cells(Rows.Count, ncol1).End(xlUp).Row
[Q1].Select
Set Plage1 = Range(Cells(1, ncol1), Cells(Ligne, ncol1))
Set Plage2 = Range(Cells(1, ncol2), Cells(Ligne, ncol2))
Set Plage3 = Range(Cells(1, ncol3), Cells(Ligne, ncol3))
Set Plage4 = Range(Cells(1, ncol4), Cells(Ligne, ncol4))
Set Graph = Charts.Add
Graph.Location Where:=xlLocationAsObject, Name:=Nom
Set Graph1 = ActiveSheet.ChartObjects(1)
With Graph1.Chart
.ChartType = xlXYScatterSmoothNoMarkers
.SeriesCollection.NewSeries
.SeriesCollection(1).Values = "=" & Nom & "!" & Plage2.Address
.SeriesCollection(1).XValues = "=" & Nom & "!" & Plage1.Address
End With
Set Graph = Charts.Add
Graph.Location Where:=xlLocationAsObject, Name:=Nom
Set Graph1 = ActiveSheet.ChartObjects(2)
With Graph1.Chart
.ChartType = xlXYScatterSmoothNoMarkers
.SeriesCollection.NewSeries
.SeriesCollection(1).Values = "=" & Nom & "!" & Plage3.Address
.SeriesCollection(1).XValues = "=" & Nom & "!" & Plage1.Address
End With
Set Graph = Charts.Add
Graph.Location Where:=xlLocationAsObject, Name:=Nom
Set Graph1 = ActiveSheet.ChartObjects(3)
With Graph1.Chart
.ChartType = xlXYScatterSmoothNoMarkers
.SeriesCollection.NewSeries
.SeriesCollection(1).Values = "=" & Nom & "!" & Plage4.Address
.SeriesCollection(1).XValues = "=" & Nom & "!" & Plage1.Address
End With
End Sub |
Partager