Re bonjour le forum,

Est-il possible d'imbriquer des fonctions, et si oui comment?
J'avoue que je ne comprends pas très bien comment fonctionnent les fonctions pour la déclaration.
Ce que je souhaite faire, c'est appeler une fonction qui me trace un graphique et dans cette fonction, faire appel à une autre fonction pour la mise en forme du graphique.
Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Function dessiner()
 
Dim Chrt As Excel.ChartObject, oChrt As Excel.ChartObject
Dim plot As Excel.Chart, plot1 As Excel.Chart
Dim maSerie As Excel.Series
 
    With Worksheets(3)
        Set Chrt = .ChartObjects.Add(.Range("G2").Left, .Range("G2").Top, 450, 165)
        Set oChrt = .ChartObjects.Add(.Range("G16").Left, .Range("G16").Top, 450, 165)
    End With
 
    Set plot = Chrt.Chart
 
    plot.SeriesCollection.NewSeries
    plot.SeriesCollection.NewSeries
    With plot
       .SeriesCollection(1).ChartType = xlXYScatterLines
       .SeriesCollection(1).Name = "Dunkelkennlinie"
       .SeriesCollection(1).XValues = Worksheets(3).Range("A2:A26")
       .SeriesCollection(1).Values = Worksheets(3).Range("B2:B26")
       .SeriesCollection(1).MarkerSize = 6
 
       .SeriesCollection(2).ChartType = xlXYScatterLines
       .SeriesCollection(2).XValues = Worksheets(3).Range("A2:A26")
       .SeriesCollection(2).Values = Worksheets(3).Range("D2:D26")
       .SeriesCollection(2).Border.ColorIndex = 3
       .SeriesCollection(2).MarkerBackgroundColorIndex = 3
       .SeriesCollection(2).MarkerForegroundColorIndex = 3
       .SeriesCollection(2).MarkerSize = 6
 
       .Axes(xlValue, xlPrimary).HasTitle = True
       .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Licht [u.A.]"
       .Axes(xlValue).AxisTitle.Font.Size = 8
       .Axes(xlValue).TickLabels.NumberFormat = "0.00"
       .Axes(xlValue).TickLabels.Font.Size = 7
       .Axes(xlValue).TickLabelPosition = xlLow
       .Axes(xlValue).Border.ColorIndex = 15
       .Axes(xlValue).MajorGridlines.Border.ColorIndex = 15
 
       .PlotArea.Border.ColorIndex = 15
       .PlotArea.Interior.ColorIndex = xlNone
       .Legend.Delete
       .ChartArea.Border.LineStyle = 0
    End With
 
    Set plot1 = oChrt.Chart
        plot1.SeriesCollection.NewSeries
        plot1.SeriesCollection.NewSeries
 
    With plot1
       .SeriesCollection(1).ChartType = xlXYScatterLines
       .SeriesCollection(1).Name = "Dunkelkennlinie"
       .SeriesCollection(1).XValues = Worksheets(3).Range("A2:A26")
       .SeriesCollection(1).Values = Worksheets(3).Range("C2:C26")
       .SeriesCollection(1).MarkerSize = 6
 
       .SeriesCollection(2).ChartType = xlXYScatterLines
       .SeriesCollection(2).XValues = Worksheets(3).Range("A2:A26")
       .SeriesCollection(2).Values = Worksheets(3).Range("E2:E26")
       .SeriesCollection(2).Border.ColorIndex = 3
       .SeriesCollection(2).MarkerBackgroundColorIndex = 3
       .SeriesCollection(2).MarkerForegroundColorIndex = 3
       .SeriesCollection(2).MarkerSize = 6
 
       .Axes(xlCategory, xlPrimary).HasTitle = True
       .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Spannung [mV]"
       .Axes(xlCategory).AxisTitle.Font.Size = 8
       .Axes(xlCategory).TickLabels.NumberFormat = "0.00"
       .Axes(xlCategory).TickLabels.Font.Size = 7
       .Axes(xlCategory).TickLabelPosition = xlLow
       .Axes(xlCategory).Border.ColorIndex = 15
 
       .Axes(xlValue, xlPrimary).HasTitle = True
       .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Licht [u.A.]"
       .Axes(xlValue).AxisTitle.Font.Size = 8
       .Axes(xlValue).TickLabels.NumberFormat = "0.00"
       .Axes(xlValue).TickLabels.Font.Size = 7
       .Axes(xlValue).TickLabelPosition = xlLow
       .Axes(xlValue).Border.ColorIndex = 15
       .Axes(xlValue).MajorGridlines.Border.ColorIndex = 15
 
       .PlotArea.Border.ColorIndex = 15
       .PlotArea.Interior.ColorIndex = xlNone
       .Legend.Delete
       .ChartArea.Border.LineStyle = 0
    End With
 
Set plot = Nothing
Set oChrt = Nothing
Set plot1 = Nothing
Set Chrt = Nothing
 
End Function
Comme vous pouvez le constater, pour mes deux graphiques, j'ai la même mise en forme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
       .Axes(xlValue, xlPrimary).HasTitle = True
       .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Licht [u.A.]"
       .Axes(xlValue).AxisTitle.Font.Size = 8
       .Axes(xlValue).TickLabels.NumberFormat = "0.00"
       .Axes(xlValue).TickLabels.Font.Size = 7
       .Axes(xlValue).TickLabelPosition = xlLow
       .Axes(xlValue).Border.ColorIndex = 15
       .Axes(xlValue).MajorGridlines.Border.ColorIndex = 15
 
       .PlotArea.Border.ColorIndex = 15
       .PlotArea.Interior.ColorIndex = xlNone
       .Legend.Delete
       .ChartArea.Border.LineStyle = 0
Est-il possible de faire une fonction pour cette mise en forme?

Johann