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 faireGraphique(nomAppli, ligFin, colDeb, colFin, titre, emp1, emp2, style)
Dim classeur As Workbook
Dim objRange As Range
Dim objChart As ChartObject
Set classeur = Workbooks(nomAppli)
With Sheets("Statistiques")
Set a1 = .Range(.Cells(2, colDeb), .Cells(ligFin, colDeb + 1))
Set a2 = .Range(.Cells(2, colFin), .Cells(ligFin, colFin))
Set objRange = Union(a1, a2)
End With
Set objChart = Sheets("Graphiques").ChartObjects.Add(emp1, emp2, 320, 220)
With objChart.Chart
.ChartStyle = style
.ChartType = xlLine
.SetSourceData Source:=objRange
.ApplyLayout (4)
.PlotBy = xlColumns
.SetElement (msoElementDataLabelRight)
.SetElement (msoElementChartTitleAboveChart)
.ChartTitle.Text = titre
End With
End Sub |
Partager