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
| Sub CreationGrafEvoUsine()
Dim DerCol As Integer, DerLig As Long, CelAdr As String, myrange As Range, mini As Long, maxi As Long
shtGrafEvoUsine.Select
DerCol = shtGrafEvoUsine.Cells(2, Columns.Count).End(xlToLeft).Column
DerLig = shtGrafEvoUsine.Range("A" & Rows.Count).End(xlUp).Row
CelAdr = Cells(DerLig, DerCol).Address
Set myrange = shtGrafEvoUsine.Range("b2:" & CelAdr)
ActiveSheet.Shapes.AddChart.Select
Let mini = Application.WorksheetFunction.Min(myrange)
Let maxi = Application.WorksheetFunction.Max(myrange)
Let mini = Application.WorksheetFunction.RoundDown(mini / 1000, 0) * 1000
Let maxi = Application.WorksheetFunction.RoundUp(maxi / 1000, 0) * 1000
With ActiveChart
.ChartType = xlLine
.ChartStyle = 2
.SetSourceData Source:=Range("A1:" & CelAdr)
.Axes(xlValue).DisplayUnit = xlThousands
.Axes(xlValue).HasDisplayUnitLabel = False
.Axes(xlValue).MajorUnit = 1000
.Axes(xlValue).MinimumScale = mini
.Axes(xlValue).MaximumScale = maxi
.HasTitle = True
.ChartTitle.Text = "PN moyen par usine"
End With
With shtGrafEvoUsine.Shapes(shtGrafEvoUsine.Shapes.Count)
.Select
.Top = shtGrafEvoUsine.Range("C15").Top
.Left = shtGrafEvoUsine.Range("C15").Left
End With
End Sub |
Partager