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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
| Sub Macro1()
'Déclaration des variables
Dim sResultatInputBox As String 'Récupére la réponse de l'inputbox
'Ouverture de la imputbox pour récupérer la période
sResultatInputBox = InputBox("Saisir une période de 1 à 13")
'Création du graphique suivant la réponse
If sResultatInputBox = 1 Then
'Ajout d'un nouveau graphique
Charts.Add
'Récupération de la plage de données
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("B2:B11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 2 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("C2:C11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 3 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("D2:D11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 4 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("E2:E11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 5 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("F2:F11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 6 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("G2:G11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 7 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("H2:H11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 8 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("I2:I11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 9 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("J2:J11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 10 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("K2:K11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 11 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("L2:L11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 12 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("M2:M11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ElseIf sResultatInputBox = 13 Then
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("N2:N11"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End If
End Sub |
Partager