Sub Macro37()
' Variable objet pointant vers le graphique ou rien
Dim oChart As Chart
'Suivant le type d'opbjet sélectionné
Select Case TypeName(Selection)
Case "Chart": Set oChart = Selection
Case "ChartArea", "PlotArea": Set oChart = Selection.Parent
Case "GridLines": Set oChart = Selection.Parent.Parent
Case Else
MsgBox "La selection n'a pas été reconnue" & vbCrLf & "Veuillez sélectionner le graphique et non un de ses éléments", vbExclamation, "Mise à jour du graphique"
Exit Sub
End Select
'si le graphique est bien sélectionné
If Not oChart Is Nothing Then
oChart.Axes(xlCategory).Select
oChart.PlotArea.Select
oChart.SeriesCollection.NewSeries
oChart.SeriesCollection(2).XValues = "=Feuil1!R29C2:R31C2"
oChart.SeriesCollection(2).Values = "=Feuil1!R29C3:R31C3"
End If
End Sub