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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
Sub GraphiquePoids()
'
' GraphiquePoids Macro
' Macro enregistrée le 18/06/2010 par bernard.maillot
'
Dim Graph As ChartObject
Dim NomFeuil, Col, PoidsIdeal
Dim NumCol As Long
Dim C As Chart
Dim WindowWidth As Double, WindowHeight As Double
Dim Adr As String
WindowWidth = ActiveWindow.UsableWidth * (100 / ActiveWindow.Zoom) - 18
WindowHeight = ActiveWindow.UsableHeight * (100 / ActiveWindow.Zoom) - 18
NomFeuil = Sheets("Data").Cells(24, 2).Value 'FrmMensurations.CBNom
For Each Graph In Worksheets("Morphotype").ChartObjects
If Graph.name = "SuiviPoids" Then
Graph.Delete
Else
GoTo Suite
End If
Next
Suite:
NumCol = Sheets(NomFeuil).Range("IV2").End(xlToLeft).Column
Col = ChifVersLetre(NumCol)
PoidsIdeal = Sheets(NomFeuil).Cells(5, 2).Value
Set Graph = Worksheets("Morphotype").ChartObjects.Add(50, 100, 870, 410)
Graph.name = "SuiviPoids"
With Graph.Chart
.ChartType = xlLineMarkers
Adr = "C5:" & Col & "5,C1:" & Col & "1"
'c'est ici à "SetSourceData" que le problème se produit parfois !!!!
.SetSourceData Source:=Sheets(NomFeuil).Range(Adr), PlotBy:=xlRows
.SeriesCollection(1).name = "=""Suivi"""
.SeriesCollection.NewSeries
.SeriesCollection(2).Values = "=" & NomFeuil & "!R7C3:R7C" & NumCol
.SeriesCollection(2).name = "=""Idéal"""
.HasTitle = True
.ChartTitle.Characters.Text = "Suivi du poids"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Dates"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Poids (kg)"
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
.Axes(xlValue).Select
.PlotArea.Select
.Axes(xlValue).Select
.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
.Axes(xlCategory).TickLabels.Orientation = 45
With .SeriesCollection(2)
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
With .Axes(xlValue)
.MinimumScale = Int(PoidsIdeal - 10)
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnit = 10
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End With
'Positionne le graphique au centre de la feuille
Graph.Top = ((WindowHeight - Selection.Height) / 2) - 1
Graph.Left = ((WindowWidth - Selection.Width) / 2) - 1
End Sub |
Partager