tupperware
XLDnaute Nouveau
Bon voilà je souhaite créer des graphiques à partir de valeurs issues de calculs ...mais j'aimerais faire ça sans avoir à passer par les feuilles Excel (cad sans 'écrire' les valeurs pour ensuite les utiliser avec un 'range').
Alors bon j'ai trouvé une méthode en utilisant des tableaux-colonnes mais dès qu'il y a trop de couples de valeurs pour le graphe (cf 'nbp' trop grand, cad qu'il y a trop de ligne aux tableaux colonnes)...ça marche plus...ça marche plus aussi si je mets trop de chiffres derrière la virgule pour x....bref je comprends plus grand chose...heeeeeeeeelp
voilà le bébé
Sub test_graph_()
Dim a As Single
Dim i As Integer, j As Integer, p As Integer, SM As Integer, nbp As Integer
SM = 10
nbp = 40
Dim table
ReDim table (1 To nbp) As Double
Dim tablex
ReDim tablex (1 To nbp) As Double
Dim tableau
ReDim tableau(1 To nbp, 1 To SM) As double
x = 2.5431896549766
x = Format(x, '0.000')
For j = 1 To SM
For i = 1 To nbp
a = (i) / 10 + j * x
tableau(i, j) = a
Next
Next
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
For p = 1 To SM
For i = 1 To nbp
table(i) = tableau(i, p)
Next
For i = 1 To nbp
tablex(i) = i
Next
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
'C'est à cette ligne que ça marche plus....snif
ActiveChart.SeriesCollection(p).XValues = tablex
ActiveChart.SeriesCollection(p).Values = table
Next
'tout ça on s'en fout un peu
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = 'youpi'
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = 'génial'
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = 'Ts'
End With
'ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = '0.000'
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.NumberFormat = '0.000'
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowNone, LegendKey:=False
ActiveChart.Shapes.AddTextbox(msoTextOrientationHorizontal, 656.63, 0#, _
60.97, 39.54).Select
Selection.Characters.Text = 'le truc de la série'
Selection.AutoScaleFont = False
With Selection.Characters(Start:=1, Length:=10).Font
.Name = 'Arial'
.FontStyle = 'Normal'
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End Sub
Merci !
Alors bon j'ai trouvé une méthode en utilisant des tableaux-colonnes mais dès qu'il y a trop de couples de valeurs pour le graphe (cf 'nbp' trop grand, cad qu'il y a trop de ligne aux tableaux colonnes)...ça marche plus...ça marche plus aussi si je mets trop de chiffres derrière la virgule pour x....bref je comprends plus grand chose...heeeeeeeeelp
voilà le bébé
Sub test_graph_()
Dim a As Single
Dim i As Integer, j As Integer, p As Integer, SM As Integer, nbp As Integer
SM = 10
nbp = 40
Dim table
ReDim table (1 To nbp) As Double
Dim tablex
ReDim tablex (1 To nbp) As Double
Dim tableau
ReDim tableau(1 To nbp, 1 To SM) As double
x = 2.5431896549766
x = Format(x, '0.000')
For j = 1 To SM
For i = 1 To nbp
a = (i) / 10 + j * x
tableau(i, j) = a
Next
Next
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
For p = 1 To SM
For i = 1 To nbp
table(i) = tableau(i, p)
Next
For i = 1 To nbp
tablex(i) = i
Next
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
'C'est à cette ligne que ça marche plus....snif
ActiveChart.SeriesCollection(p).XValues = tablex
ActiveChart.SeriesCollection(p).Values = table
Next
'tout ça on s'en fout un peu
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = 'youpi'
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = 'génial'
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = 'Ts'
End With
'ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = '0.000'
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.NumberFormat = '0.000'
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowNone, LegendKey:=False
ActiveChart.Shapes.AddTextbox(msoTextOrientationHorizontal, 656.63, 0#, _
60.97, 39.54).Select
Selection.Characters.Text = 'le truc de la série'
Selection.AutoScaleFont = False
With Selection.Characters(Start:=1, Length:=10).Font
.Name = 'Arial'
.FontStyle = 'Normal'
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End Sub
Merci !