procedure graphe
Le
jean-luc Guitard
bonjour,
Dans cette petite macro (pour effectuer plusieurs graphiques) sur excel 2003
il ne trouve pas erreur à ".SeriesCollection.Add plage, xlColumns, True,
True " alors qu'il en trouve une dans excel 2010
Erreur d'execution "5" argument ou appel de procédure incorrect
je ne comprends pas pourquoi, peut-on simplifier cette procédure?
merci à ceux qui savent, bonne journée
Sub Graph_L1()
Application.ScreenUpdating = False
Sheets("Source").Visible = True
If Sheets("L1").ChartObjects.Count <> 0 Then
Sheets("L1").ChartObjects.Delete
Sheets("all active").Select
Range("H1", Range("H65536").End(xlUp)).AdvancedFilter
Action:=xlFilterCopy, CopyToRange:=Range("AR1"), Unique:=True
DerLigne = Range("AR65536").End(xlUp).Row - 1
j = 1
For I = 11 To 11 + DerLigne
Sheets("Source").Select
If Cells(2, I) <> 0 Then
Ma_plage = Union(Range(Cells(1, 10), Cells(4, 10)),
Range(Cells(1, I), Cells(4, I))).Address
Set Risque_Marque = Worksheets(4).ChartObjects.Add(300, 1,
400, 220)
With Risque_Marque.Chart
.SetSourceData Range(Ma_plage), PlotBy:=xlColumns
.ChartType = xl3DPieExploded
.SeriesCollection.Add plage, xlColumns, True, True
.SeriesCollection(1).ApplyDataLabels AutoText:=True,
LegendKey:= _
False, HasLeaderLines:=True,
ShowSeriesName:úlse, ShowCategoryName:= _
True, ShowValue:úlse,
ShowPercentage:=True, ShowBubbleSize:úlse
.ChartTitle.Font.Name = "Clarendon BT"
.ChartTitle.Font.Size = 20
.HasLegend = False
End With
ThisWorkbook.Sheets(4).ChartObjects(j).Activate
ActiveChart.PlotArea.Select
Selection.Width = 300
Selection.Left = 60
Selection.Top = 60
Selection.ClearFormats
ActiveChart.ChartArea.Select
Sheets(4).ChartObjects(j).RoundedCorners = True
Sheets(4).ChartObjects(j).Shadow = True
Selection.Fill.TwoColorGradient
Style:=msoGradientDiagonalUp, Variant:=1
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 44
.Fill.BackColor.SchemeColor = 2
End With
ActiveChart.SeriesCollection(1).Select
Selection.Explosion = 6
For Each p In
ActiveChart.SeriesCollection(1).Points
If Mid(p.DataLabel.Text, 7, 2) = 0 Then
p.HasDataLabel = False
Next p
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.Size = 18
End With
For a = 1 To 3
Niveau = Sheets("Source").Cells(a + 1, 10).Value
If Niveau = "Level1" Then
Risque_Marque.Chart.SeriesCollection(1).Points(a).Interior.ColorIndex = 4
If Niveau = "Level2" Then
Risque_Marque.Chart.SeriesCollection(1).Points(a).Interior.ColorIndex = 7
If Niveau = "Level3" Then
Risque_Marque.Chart.SeriesCollection(1).Points(a).Interior.ColorIndex = 6
Next a
j = j + 1
End If
Next I
Placement
Sheets("L1").Select
Sheets("L1").Cells(1, 1).Select
Sheets("Source").Visible = False
End Sub
Sub Placement()
Sheets(4).Select
NbparLigne = 2
Largeur = 255
Hauteur = 255
Ecart = 10
nbtot = ActiveSheet.ChartObjects.Count
For I = 0 To nbtot - 1
With ActiveSheet.ChartObjects(I + 1)
.Width = Largeur
.Height = Hauteur
.Left = Ecart + (I Mod NbparLigne) * (Ecart + Largeur)
.Top = Ecart + Int(I / NbparLigne) * (Ecart + Hauteur)
End With
Next I
End Sub
Dans cette petite macro (pour effectuer plusieurs graphiques) sur excel 2003
il ne trouve pas erreur à ".SeriesCollection.Add plage, xlColumns, True,
True " alors qu'il en trouve une dans excel 2010
Erreur d'execution "5" argument ou appel de procédure incorrect
je ne comprends pas pourquoi, peut-on simplifier cette procédure?
merci à ceux qui savent, bonne journée
Sub Graph_L1()
Application.ScreenUpdating = False
Sheets("Source").Visible = True
If Sheets("L1").ChartObjects.Count <> 0 Then
Sheets("L1").ChartObjects.Delete
Sheets("all active").Select
Range("H1", Range("H65536").End(xlUp)).AdvancedFilter
Action:=xlFilterCopy, CopyToRange:=Range("AR1"), Unique:=True
DerLigne = Range("AR65536").End(xlUp).Row - 1
j = 1
For I = 11 To 11 + DerLigne
Sheets("Source").Select
If Cells(2, I) <> 0 Then
Ma_plage = Union(Range(Cells(1, 10), Cells(4, 10)),
Range(Cells(1, I), Cells(4, I))).Address
Set Risque_Marque = Worksheets(4).ChartObjects.Add(300, 1,
400, 220)
With Risque_Marque.Chart
.SetSourceData Range(Ma_plage), PlotBy:=xlColumns
.ChartType = xl3DPieExploded
.SeriesCollection.Add plage, xlColumns, True, True
.SeriesCollection(1).ApplyDataLabels AutoText:=True,
LegendKey:= _
False, HasLeaderLines:=True,
ShowSeriesName:úlse, ShowCategoryName:= _
True, ShowValue:úlse,
ShowPercentage:=True, ShowBubbleSize:úlse
.ChartTitle.Font.Name = "Clarendon BT"
.ChartTitle.Font.Size = 20
.HasLegend = False
End With
ThisWorkbook.Sheets(4).ChartObjects(j).Activate
ActiveChart.PlotArea.Select
Selection.Width = 300
Selection.Left = 60
Selection.Top = 60
Selection.ClearFormats
ActiveChart.ChartArea.Select
Sheets(4).ChartObjects(j).RoundedCorners = True
Sheets(4).ChartObjects(j).Shadow = True
Selection.Fill.TwoColorGradient
Style:=msoGradientDiagonalUp, Variant:=1
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 44
.Fill.BackColor.SchemeColor = 2
End With
ActiveChart.SeriesCollection(1).Select
Selection.Explosion = 6
For Each p In
ActiveChart.SeriesCollection(1).Points
If Mid(p.DataLabel.Text, 7, 2) = 0 Then
p.HasDataLabel = False
Next p
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.Size = 18
End With
For a = 1 To 3
Niveau = Sheets("Source").Cells(a + 1, 10).Value
If Niveau = "Level1" Then
Risque_Marque.Chart.SeriesCollection(1).Points(a).Interior.ColorIndex = 4
If Niveau = "Level2" Then
Risque_Marque.Chart.SeriesCollection(1).Points(a).Interior.ColorIndex = 7
If Niveau = "Level3" Then
Risque_Marque.Chart.SeriesCollection(1).Points(a).Interior.ColorIndex = 6
Next a
j = j + 1
End If
Next I
Placement
Sheets("L1").Select
Sheets("L1").Cells(1, 1).Select
Sheets("Source").Visible = False
End Sub
Sub Placement()
Sheets(4).Select
NbparLigne = 2
Largeur = 255
Hauteur = 255
Ecart = 10
nbtot = ActiveSheet.ChartObjects.Count
For I = 0 To nbtot - 1
With ActiveSheet.ChartObjects(I + 1)
.Width = Largeur
.Height = Hauteur
.Left = Ecart + (I Mod NbparLigne) * (Ecart + Largeur)
.Top = Ecart + Int(I / NbparLigne) * (Ecart + Hauteur)
End With
Next I
End Sub

Poser une question


Sur l'autre c'était plage ou Ma_plage
Un truc qui n'est pas défini.
--
LSteph
On 29 déc, 07:43, "jean-luc Guitard"
donc c'était plage, avec Ma_plage sur le 2010 ça marche mais je ne comprends
pas pourquoi
ça marche sur excel 2003 avec plage et pas sur le 2010?
"LSteph" discussion :
"plage" doit être une variable range; tel quel, utilise "Range(plage)"
(ou range(Ma_Plage) ).
Cordialement.
Daniel
Pour "plage" il n'y a rien dans ce qu'on lit dans le code de défini
alors que pour "Ma_plage" on a au moins une adresse
Ma_plage = Union(Range(Cells(1, 10), Cells(4, 10)),Range(Cells(1, I),
Cells(4, I))).Address
donc je suppose que dans ton autre classeur il y a quelquechose que
désigne "plage"
sans doute un objet ou variable définie dans un autre module
globalement.
On 29 déc, 11:41, "jean-luc Guitard"
les programmes sont identiques et il n' y a rien qui désigne "plage"dans
excel 2003
mais ça fonctionne si je mets Ma_plage dans excel 2010 à la place de plage