Sub Temperature_plage_date()
Dim F1 As Worksheet, Plage As Range, k&, derlin&
Set F1 =Feuil12
Application.ScreenUpdating = False
On Error Resume Next
F1.Shapes("Graphique1").Delete
If Feuil1.TextBox1 = "" Or Feuil1.TextBox2 = "" Then Exit Sub
With Feuil3
For k = 2 To .[A1048576].End(3).Row
If CDate(.Cells(k, 1)) >= CDate(Feuil1.TextBox1) And CDate(.Cells(k, 1)) <= CDate(Feuil1.TextBox2) Then
If Plage Is Nothing Then
Set Plage = Union(.Cells(k, 3), .Cells(k, 13), .Cells(k, 5))
Else
Set Plage = Union(Plage, .Cells(k, 3), .Cells(k, 13), .Cells(k, 5))
End If
End If
Next
End With
If Plage Is Nothing Then
MsgBox "Pas de données", vbExclamation, "Erreur"
Exit Sub
Else
Charts.Add
With ActiveChart
.ChartType = xlLine
.SetSourceData Source:=Plage, PlotBy:=xlColumns
.Location Where:=xlLocationAsObject, Name:=F1.Name
End With
ActiveSheet.ChartObjects("Graphique1").Activate
ActiveChart.ChartArea.Select
[COLOR="green"] ' derlin = Sheets("Données").Range("R1048576").End(xlUp).Row 'Excel 2007 et sup[/COLOR]
derlin = Sheets("Données").Range("R65536").End(xlUp).Row ' Excel < à XL 2007
ActiveChart.SeriesCollection(1).XValues = "='Données'!$R$2:$R$" & derlin
ActiveChart.Parent.Name = "Graphique1"
End If
End Sub