1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Private Sub UserForm_Initialize()
Dim Feuille As Worksheet, compteur As Long
Set Feuille = ThisWorkbook.Worksheets("Feuil1")
Set Plage = Feuille.UsedRange
Me.ListBox2.MultiSelect = fmMultiSelectMulti
Me.ListBox1.MultiSelect = fmMultiSelectMulti
For compteur = 12 To Plage.Columns.Count
Me.ListBox1.AddItem Plage.Cells(compteur).Value
Me.ListBox2.AddItem Plage.Cells(5, 2)
Next compteur
End Sub
Private Sub CommandButton2_Click()
Dim Graphe As Chart, compteur As Long, MaFeuille As Worksheet
Dim PlageX As Range, PlageY As Range, MaSerie As Series
For compteur = 1 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(compteur) Then
If Graphe Is Nothing Then
Set Graphe = ThisWorkbook.Charts.Add
Graphe.ChartArea.Clear
Graphe.ChartType = xlXYScatter
End If
Set PlageY = Plage.Columns(Me.ListBox1.ListIndex + 1)
Set PlageX = Sheets("Feuil1").Range("B7:B52")
Set MaSerie = Graphe.SeriesCollection.NewSeries
With MaSerie
.Values = Plage.Columns(Me.ListBox1.ListIndex + 1)
.XValues = Sheets("Feuil1").Range("B7:B52") -> (il est vrai que mon compteur et ma ListBox2 ne servent à rien ici)
End With
End If
Next compteur
End Sub |
Partager