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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| Private Sub CbtOk_Click()
Dim graphe As Chart
Dim fsource As Worksheet
Dim plagedonnée As Range
Dim nom As String
Dim fin As Integer
Dim derligne As Integer
Dim i As Integer
Dim trouve As Range
Dim lgraphe As Integer
Dim plageX As Range
Dim plageY1 As Range
Dim plageY2 As Range
Dim maserie1 As Range, maserie2 As Range
Application.ScreenUpdating = False
fin = Me.ListBox1.ListCount
Set fsource = ThisWorkbook.Worksheets("graphe")
derligne = fsource.Range("B65536").End(xlUp).Row
Set plagenom = fsource.Range(Cells(1, 2), Cells(derligne, 2))
For i = 1 To fin - 1
nom = ""
With ListBox1
If .Selected(i) = True Then nom = .List(i)
End With
If nom <> "" Then
Set trouve = plagenom.Find(nom, plagenom.Cells(1), xlValues, xlWhole, xlByColumns, xlNext)
lgraphe = trouve.Row
coldroite = Range(Cells(lgraphe + 1, 100)).End(xlLeft).Column
Set graphe = ThisWorkbook.Charts.Add
ActiveSheet.Name = Left(nom, 30)
graphe.ChartArea.clear
graphe.ChartType = xlXYScatterLines
Set plageX = fsource.Range(Cells(lgraphe + 3, 2), Cells(lgraphe + 3, coldroite))
Set plageY1 = fsource.Range(Cells(lgraphe + 5, 2), Cells(lgraphe + 5, coldroite))
Set plageY2 = fsource.Range(Cells(lgraphe + 6, 2), Cells(lgraphe + 6, coldroite))
Set maserie1 = graphe.SeriesCollection.NewSeries
With maserie1
.Values = plageY1
.XValues = plageX
.Name = fsource.Cells(lgraphe + 5, 1).Value
End With
Set maserie2 = graphe.SeriesCollection.NewSeries
With maserie2
.Values = plageY2
.XValues = plageX
.Name = fsource.Cells(lgraphe + 6, 1).Value
End With
End If
Next i
UserForm1.Hide
Unload UserForm1
Application.ScreenUpdating = True
End Sub |
Partager