Bonjour,
et merci de t'interresser à mon pb même si j'ai réussi à le contourner en faisant une nouvelle macro pour cette feuille là mais j'aimerais savoir ce qui pouvait poser pb.
ceci est la macro qui dessine mon graphe
calcul_nb_colonnes2 me calcule le numéro de colonne qui correspond à certains titres de colonnes et calcul_nb_lignes me donne la première ligne vide
prod correspond au nom de la feuille sur laquelle on affiche le graphe.
Sub dessin_du_graphique(prod As String)
'
Dim nb_colonnes As Integer, tot_def As Integer, valor As Integer, code As Integer, nb_lignes As Integer, i As Integer
Dim x As Integer, code2 As String, k As Integer
calcul_nb_colonnes2 nb_colonnes, tot_def, valor, code
calcul_nb_lignes nb_lignes
ExecuteExcel4Macro 'SET.NAME(''test_graph'',''GRAPH'')'
'm indique que j ai un graphe sur ma feuille ce qui me permet de le supprimer par la suite
valor = valor - 1
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets(prod).Range('A' & (nb_lignes + 1)), PlotBy:= _
xlColumns
For i = 1 To valor - 1
ActiveChart.SeriesCollection.NewSeries
Next i
For i = 1 To valor
code2 = '=('
For k = 0 To nb_lignes - 6
code2 = code2 & prod & '!R' & (nb_lignes - k - 1) & 'C1,'
Next k
code2 = code2 & prod & '!R' & (nb_lignes - k - 1) & 'C1)'
ActiveChart.SeriesCollection(i).XValues = code2
code2 = '='
For k = 0 To nb_lignes - 6
code2 = code2 & prod & '!R' & (nb_lignes - k - 1) & 'C' & (i + 1) & ','
Next k
code2 = code2 & prod & '!R' & (nb_lignes - k - 1) & 'C' & (i + 1) & ''
Dim active
Set active = ActiveChart.SeriesCollection
ActiveChart.SeriesCollection(i).Values = code2
ActiveChart.SeriesCollection(i).Select
code2 = '=' & prod & '!R3C' & (i + 1)
ActiveChart.SeriesCollection(i).Name = code2 'c est ici que j ai mon pb
Next i
ActiveChart.Location Where:=xlLocationAsObject, Name:=prod
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
ActiveChart.Axes(xlCategory).Select
ActiveChart.ChartArea.Select
If prod = 'graph' Then
x = 4
ElseIf prod = 'graph_12_mois' Then
x = 4
End If
ActiveSheet.Shapes(1).Select
ActiveSheet.Shapes(valor + x).IncrementLeft -145.2
'attention, ce chiffre ''''' varie en fonction du nb de boutons aussi
ActiveSheet.Shapes(valor + x).IncrementTop (16 * nb_lignes)
ActiveSheet.ChartObjects(1).Activate
ActiveChart.ChartArea.Select
ActiveSheet.Shapes(valor + x).ScaleWidth 1.73, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes(valor + x).ScaleHeight 1.73, msoFalse, _
msoScaleFromTopLeft
ActiveChart.Legend.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = 'Arial'
.FontStyle = 'Normal'
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
Selection.Position = xlTop
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = 'Arial'
.FontStyle = 'Normal'
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = 'Arial'
.FontStyle = 'Normal'
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
changement_valor valor, 1 'ne fait juste qu'un chagement de type de graphe
'pour la colonne valor, le graphe est alors une courbe
changement_quadrillage 1 'ceci me rend mon quadrillage blc
Dim Ht As Integer, Lg As Integer
ActiveSheet.ChartObjects(1).Activate
ActiveWindow.Visible = False
Ht = 100 'hauteur du graphique en mm
Lg = 250 'largeur en mm
With Selection 'je défini ici la taille de mon graphe
.Height = Ht * 2.925
.Width = Lg * 2.66
End With
Range('a1').Select
End Sub
je n'ai mis que la partie qui m'embête
merci encore