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
| Private Sub CommandButton3_Click()
Dim MyGraph As ChartObject
Dim cLigne As Integer
Dim cColonne As Integer
Dim ligneTableau As Integer
cLigne = 1
cColonne = 2
ligneTableau = 4
'Créer Tableau et initialiser compteurs
Call UnprotectMe
Do
ligneTableau = ligneTableau + 2
If (Cells(ligneTableau, 2).Value <> "") And (Cells(ligneTableau, 22).Value <> "") Then
Cells(cLigne, 40) = Cells(ligneTableau, 2)
Cells(cLigne, 41) = Cells(ligneTableau, 34)
cLigne = cLigne + 1
End If
Loop Until (ligneTableau = 32)
'Créer Graphe
'Range("AN1:AO" & cLigne - 1).Select
On Error Resume Next
Set MyGraph = ActiveSheet.ChartObjects(1)
On Error GoTo 0
If MyGraph Is Nothing Then
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Me.Range("AN1:AO" & cLigne - 1), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Gradient de cadence entre machine"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Machine"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Cadence (pces/min)"
End With
ActiveChart.HasLegend = False
ActiveSheet.ChartObjects(1).Left = Range("I36").Left
ActiveSheet.ChartObjects(1).Top = Range("I36").Top
Else
MyGraph.Activate
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("AN1:AO" & cLigne - 1), PlotBy:=xlColumns
End If
' Windows("Feuille_VGRAPH_Groupe_v6.xls").SmallScroll Down:=-15
' Windows("Feuille_VGRAPH_Groupe_v6.xls").LargeScroll ToRight:=-1
ActiveWindow.Visible = False
Range("D34").Select
Call ProtectMe
End Sub |
Partager