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 48 49 50 51 52 53 54 55 56 57
| Sub generation_graphiques()
Dim i As Integer, j As Integer, k As Integer
Dim col_graphe As Integer
Dim nb_lignes As Double, line_value As Double
Dim benchmark As Workbook, graphiques As Workbook
Set benchmark = ActiveWorkbook
'Comptage des lignes de l'onglet "Glossaire"
nb_lignes = benchmark.Sheets("Glossaire").Range("A" & Rows.Count).End(xlUp).Row
'Repérage de la colonne contenant l'info "Graphique"
col_graphe = 1
While Sheets("Glossaire").Cells(1, col_graphe).Value <> "Graphique"
col_graphe = col_graphe + 1
Wend
'création d'un nouveau classeur
Workbooks.Add
ActiveWorkbook.SaveAs ("Graphiques benchmark.xlsx")
Set graphiques = Workbooks("Graphiques benchmark.xlsx")
'La colonne "Graphique" est parcourue ligne par ligne, s'il y a un X, on génère un graphique selon l'information contenue dans la colonne suivante
For i = 1 To nb_lignes
If benchmark.Sheets("Glossaire").Cells(i, col_graphe).Value = "X" Then
line_value = benchmark.Sheets("Glossaire").Cells(i, 7).Value
graphiques.Sheets.Add
graphiques.ActiveSheet.Name = benchmark.Sheets("glossaire").Cells(i, 2).Value
graphiques.ActiveSheet.Shapes.AddChart.Select
'Cas du graphiques en lignes
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Range(benchmark.Sheets("interface").Cells(line_value + 1, 2), benchmark.Sheets("interface").Cells(line_value + 20, 16))
ActiveChart.SeriesCollection(1).XValues = Range(benchmark.Sheets("interface").Cells(3, 3), benchmark.Sheets("interface").Cells(3, 17))
End If
Next i
End Sub |
Partager