N
nico64
Guest
salut,
g un prob je n'arrive pas à afficher un graph a partir d'un userform qui determine la plage, la serie et la période à afficher.
voici le code de l'userform ou sinon le fichier a télécharger
merci d'avance
Option Explicit
Private Sub ComboBox1_Change()
End Sub
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
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 = Feuil1.Range('A' & Debut & ':A' & Fin)
Application.ScreenUpdating = False
Worksheets(1).ChartObjects('Graphique 1').Activate
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
ActiveChart.SeriesCollection.NewSeries
Set Plage2 = Feuil1.Range(Feuil1.Cells(Debut, i + 2).Address & ':' & Feuil1.Cells(Fin, i + 2).Address)
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
Next i
Application.ScreenUpdating = True
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Initialize()
Dim X As Byte
Dim Y As Integer
For X = 2 To 6
ListBox1.AddItem Feuil1.Cells(1, X)
Next X
For Y = 2 To 366
ComboBox1.AddItem Format(Feuil1.Range('A' & Y), 'dd mmmm')
ComboBox2.AddItem Format(Feuil1.Range('A' & Y), 'dd mmmm')
Next Y
End Sub
[file name=userformdate.zip size=13866]http://www.excel-downloads.com/components/com_simpleboard/uploaded/files/userformdate.zip[/file]
g un prob je n'arrive pas à afficher un graph a partir d'un userform qui determine la plage, la serie et la période à afficher.
voici le code de l'userform ou sinon le fichier a télécharger
merci d'avance
Option Explicit
Private Sub ComboBox1_Change()
End Sub
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
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 = Feuil1.Range('A' & Debut & ':A' & Fin)
Application.ScreenUpdating = False
Worksheets(1).ChartObjects('Graphique 1').Activate
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
ActiveChart.SeriesCollection.NewSeries
Set Plage2 = Feuil1.Range(Feuil1.Cells(Debut, i + 2).Address & ':' & Feuil1.Cells(Fin, i + 2).Address)
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
Next i
Application.ScreenUpdating = True
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Initialize()
Dim X As Byte
Dim Y As Integer
For X = 2 To 6
ListBox1.AddItem Feuil1.Cells(1, X)
Next X
For Y = 2 To 366
ComboBox1.AddItem Format(Feuil1.Range('A' & Y), 'dd mmmm')
ComboBox2.AddItem Format(Feuil1.Range('A' & Y), 'dd mmmm')
Next Y
End Sub
[file name=userformdate.zip size=13866]http://www.excel-downloads.com/components/com_simpleboard/uploaded/files/userformdate.zip[/file]