Sub Test()
Dim DC As Integer, i As Integer, j As Integer, Nb_Occurences As Integer, DL As Integer
Dim Adresse_DC(1 To 10) As String
Dim Mon_Graph As ChartObject
Dim Message, Titre, Ligne
Dim La_Ligne_Affichage(1 To 10) As Long
Dim Position As Byte
Dim myCht As ChartObject
Dim RngCht As Range
Dim ChrtObj As ChartObject
Application.ScreenUpdating = False
Sheets("Graphique").Select
With Range(Cells(1, 1), Cells(15, 1)).EntireRow
.ClearContents
.ClearFormats
End With
For Each Mon_Graph In Sheets("Graphique").ChartObjects
Mon_Graph.Delete
Next
Sheets("ONGLET DATAS").Select
DC = Cells(6, 256).End(xlToLeft).Column 'Derniere Colonne
Range(Cells(6, 6), Cells(6, DC)).Copy Sheets("Graphique").Cells(1, 1) 'Les dates
Sheets("ONGLET DATAS").Select
Message = "Veuillez indiquer la(les) ligne(s) que vous souhaitez illuster. Pour l'affichage de lignes multiples, veuillez les séparer par un point-virgule--> ; Maximum = 10 lignes différentes. Merci !"
Titre = "Choix de la ligne..."
Ligne = InputBox(Message, Titre)
Nb_Occurences = 1
For i = 1 To Len(Ligne)
If Mid(Ligne, i, 1) = ";" Then Nb_Occurences = Nb_Occurences + 1
Next i
For i = 1 To Nb_Occurences
If Nb_Occurences = 1 Then
La_Ligne_Affichage(1) = Ligne
Else
If i = Nb_Occurences Then
La_Ligne_Affichage(i) = Ligne
Else
Position = InStr(Ligne, ";")
La_Ligne_Affichage(i) = Mid(Ligne, 1, Position - 1)
Ligne = Mid(Ligne, Position + 1, Len(Ligne) - Position)
End If
End If
Range(Cells(La_Ligne_Affichage(i), 6), Cells(La_Ligne_Affichage(i), DC)).Copy Sheets("Graphique").Cells(1 + i, 1) 'les données
Next i
Sheets("Graphique").Select
DC = Cells(1, 256).End(xlToLeft).Column
DL = Cells(65536, 1).End(xlUp).Row
For i = 2 To DL
For j = 1 To DC
On Error Resume Next
If Cells(i, j).Value = "" Then Cells(i, j).Value = "=NA()"
On Error GoTo 0
Next j
Next i
Range(Cells(1, 1), Cells(DL, DC)).Copy
Cells(1, 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Adresse_DC(1) = Cells(1, DC).Address
Adresse_DC(2) = Cells(2, DC).Address
'ActiveSheet.Shapes.AddChart.Select
'Sheets("Graphique").Select
'Charts.Add
Set myCht = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=375, Top:=75, Height:=225)
With myCht.Chart
.ChartType = xlLine
' ActiveChart.SeriesCollection.NewSeries
' ActiveChart.SeriesCollection(1).Name = "=""Valeurs 1"""
' ActiveChart.SeriesCollection(1).Values = "='Graphique'!$A$2:" & Adresse_DC(2)
' ActiveChart.SeriesCollection(1).XValues = "='Graphique'!$A$1:" & Adresse_DC(1)
If Nb_Occurences > 0 Then
For i = 1 To Nb_Occurences
Adresse_DC(1 + i) = Cells(1 + i, DC).Address
With .SeriesCollection.NewSeries
'.Name = "=""Valeurs " & i
Range("='Graphique'!$A$" & (i + 1) & ":" & Adresse_DC(1 + i)).Select
.Values = Range("='Graphique'!$A$" & (i + 1) & ":" & Adresse_DC(1 + i))
End With
Next i
End If
End With
'r:
' For i = 1 To ActiveChart.SeriesCollection.Count
' On Error Resume Next
' If Left(ActiveChart.SeriesCollection(i).Name, 5) = "Série" Then
' ActiveChart.SeriesCollection(i).Delete
' GoTo r
' End If
' On Error GoTo 0
'Next i
End Sub