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
|
Private Sub courbe_ajoutErrorBars(shapeGraph As Shape, dataWorksheet As Worksheet)
Dim selectionDate_init As Range
Dim selectionValue_init As Range
'Dim shapeGraph As Shape
Dim mySelection As Range
Dim mySerie As Series
Dim count As Integer
' **********************************
' Selection des colonnes
Set selectionDate_init = dataWorksheet.Range("A1")
Set selectionValue_init = dataWorksheet.Range("B1")
' **********************************
Set mySelection = selectionDate_init.Offset(1, 0)
count = 0
While mySelection.value <> ""
count = count + 1
Set mySelection = mySelection.Offset(1, 0)
Wend
Dim selectionErrorX As Range
Dim selectionErrorY As Range
Set selectionErrorX = selectionDate_init.Offset(0, 3)
Set selectionErrorY = selectionValue_init.Offset(0, 3)
Set selectionErrorX = Range(selectionErrorX.Offset(1, 0), selectionErrorX.Offset(count, 0))
Set selectionErrorY = Range(selectionErrorY.Offset(1, 0), selectionErrorY.Offset(count, 0))
With shapeGraph.Chart
.ChartType = xlXYScatter
Set mySerie = .SeriesCollection(dataWorksheet.Name)
With mySerie
.HasErrorBars = True
.ErrorBars.EndStyle = xlNoCap
.ErrorBar Direction:=xlX, Include:=xlPlusValues, Type:=xlCustom, Amount:=selectionErrorX ', MinusValues:="={#N/A}"
.ErrorBar Direction:=xlY, Include:=xlPlusValues, Type:=xlCustom, Amount:=selectionErrorY ', MinusValues:="={#N/A}"
.ErrorBars.Border.Weight = xlMedium
.ErrorBars.Border.color = .MarkerForegroundColor
End With
End With
' debug
Application.ScreenUpdating = True ' force le rafraichissemnt de l'ecran
MsgBox "courbe ajoutée"
End Sub |
Partager