ca a l'air de marcher cependant j'ai un soucis de sélection de plage de données parce que j'ai décalé ma plage de données de 200 lignes vers le bas donc du coup il n'a plus les bonnes rèf (avant c'était de a1:j38, maintenant c'est de a200:j237) et je n'arrive pas à la recalibrer, peut être y'a t'il des erreurs?
ps: les sheets(1) sont normalement les sheets nommées avec le code que tu m'as donné
(ceci est fait sur un modèle de michel xld
)
Option Explicit
Private Sub CommandButton1_Click()
Dim X As Byte, i As Byte
Dim j As Integer, Debut As Integer, Fin As Integer
Dim Plage As Range, Plage2 As Range
Dim Accord As Boolean
If ListBox1.Value = '' Then Exit Sub
If ComboBox1.ListIndex = -1 Or ComboBox2.ListIndex = -1 Then Exit Sub
If ComboBox1.ListIndex > ComboBox2.ListIndex Then
MsgBox 'La date de fin ne peut pas etre antérieure à la date de début .'
Exit Sub
End If
Debut = ComboBox1.ListIndex + 2
Fin = ComboBox2.ListIndex + 2
Set Plage = Sheets(1).Range('A' & Debut & ':A' & Fin)
Application.ScreenUpdating = False
Charts('graph' & 1).Activate
'****premiere boucle pour vérifier qu'au moins une courbe peut etre créée
For i = 0 To ListBox1.ListCount - 1 'boucle sur les éléments de la listbox
If ListBox1.Selected(i) = True Then
Set Plage2 = Sheets(1).Range(Sheets(1).Cells(Debut, i + 2).Address & ':' & Sheets(1).Cells(Fin, i + 2).Address)
If Application.CountBlank(Plage2) <> Plage2.Count Then
Accord = True
Exit For
End If
End If
Next i
If Accord = False Then Exit Sub
'*************************************************************************
For j = ActiveChart.SeriesCollection.Count To 1 Step -1
ActiveChart.SeriesCollection(j).Delete
Next j
For i = 0 To ListBox1.ListCount - 1 'boucle sur les éléments de la listbox
If ListBox1.Selected(i) = True Then
X = X + 1
Set Plage2 = Sheets(1).Range(Sheets(1).Cells(Debut, i + 2).Address & ':' & Sheets(1).Cells(Fin, i + 2).Address)
If Application.CountBlank(Plage2) <> Plage2.Count Then 'verif si plage est non vide
ActiveChart.ChartType = xlLine
ActiveChart.SeriesCollection.NewSeries
With ActiveChart.Axes(xlCategory)
.TickLabelSpacing = 1
End With
ActiveChart.SeriesCollection(X).Values = Plage2
If X = 1 Then ActiveChart.SeriesCollection(X).XValues = Plage
ActiveChart.SeriesCollection(X).Name = ListBox1.List(i) ' nom de la courbe
ActiveChart.SeriesCollection(X).Border.ColorIndex = i + 4
End If
End If
Next i
Unload Me
Sheets('graph' & 1).Select
Application.ScreenUpdating = True
End Sub
Private Sub ListBox1_Click()
End Sub
Private Sub UserForm_Initialize()
Dim Y As Byte
Dim X As Integer, nba As Byte
nba = Sheets(CStr(Sheets('filtre').Range('a1000'))).Range('a100').Value
For X = 2 To nba + 1
ListBox1.AddItem Sheets(1).Cells(200, X)
Next X
For Y = 200 To 237
ComboBox1.AddItem Format(Sheets(CStr(Sheets('filtre').Range('a1000'))).Range('A' & Y))
ComboBox2.AddItem Format(Sheets(CStr(Sheets('filtre').Range('a1000'))).Range('A' & Y))
Next Y
End Sub
Message édité par: toubib, à: 07/10/2005 15:39