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
| Sub Macro3()
'recupération de la valeur de NbColonne
Sheets("Feuil2").Visible = True
Sheets("Feuil2").Select
NbColonne = Range("A1").Value
Sheets("Feuil2").Visible = False
Sheets("Feuil1").Select
MsgBox (NbColonne)
'Ajout du Graphique
Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("B4:V34"), PlotBy:=xlColumn
'Nom des différentes courbes du graphique
For i = 1 To NbColonne
If i <= NbColonne - 6 Then
If i Mod 2 = 0 Then
With ActiveChart.SeriesCollection(i)
.Name = Worksheets(1).Cells(2, i).Value & "(Traité)"
End With
ElseIf i Mod 2 <> 0 Then
With ActiveChart.SeriesCollection(i)
.Name = Worksheets(1).Cells(2, i + 1).Value & "(Reçu)"
End With
End If
ElseIf i >= NbColonne - 5 Then
MsgBox (i)
With ActiveChart.SeriesCollection(i)
.Name = Worksheets(1).Cells(2, i + 1).Value
End With
End If
Next i
End Sub |
Partager