Bonjour,
J'ai testé mes tableaux sur un autre ordi et j'ai eu la surprise de constater qu'une macro ne fonctionnait pas alors qu'elle fonctionne bien chez moi. Je viens de vérifier à l'instant. Est-ce courant comme désagrément ou est ce anormal? Je vous mets le code. Sur l'autre ordi l'erreur donnée était au niveau des full series collection.
Qqun aurait une idée de quoi corriger si qqchose est mal écrit? Merci
Sub graphcouleurse31a()
' graphcouleurse31a Macro
'
Dim wsData As Worksheet, wsChart As Worksheet
Dim rngChart As Range
Dim objChart As ChartObject
Dim objLE As LegendEntry
ActiveSheet.unprotect Password:="toto"
Application.ScreenUpdating = False
Set wsData = Feuil43
Set wsChart = ActiveSheet
On Error Resume Next
wsChart.ChartObjects(1).Delete
On Error GoTo 0
Set objChart = wsChart.ChartObjects.Add _
(Left:=wsChart.Columns("c").Left, _
Top:=wsChart.Rows(9).Top, _
Width:=800, _
Height:=280)
With objChart.Chart
.ChartType = xlColumnStacked
.SetSourceData Source:=Feuil43.Range("A3:E33")
.HasTitle = True
.ChartTitle.Text = "Répartition des fiches par couleur - " & wsData.Cells.Range("a2")
.HasLegend = True
.Legend.Position = xlTop
With .Parent
.Placement = xlFreeFloating
.Name = "Graphique " & wsData.Cells(1)
End With
.FullSeriesCollection(1).Format.Fill.ForeColor.RGB = RGB(255, 0, 0) 'rouge
.FullSeriesCollection(2).Format.Fill.ForeColor.RGB = RGB(255, 255, 0) 'jaune
.FullSeriesCollection(3).Format.Fill.ForeColor.RGB = RGB(146, 208, 80) 'vert
.FullSeriesCollection(4).Format.Fill.ForeColor.RGB = RGB(0, 176, 80) 'vert2
With .Legend
.Font.Bold = True
.Font.Italic = True
For Each objLE In .LegendEntries
objLE.Font.Color = objLE.LegendKey.Interior.Color
Next
End With
End With
Set objChart = Nothing
Set rngChart = Nothing
Set wsChart = Nothing: Set wsData = Nothing
ActiveSheet.protect Password:="toto", DrawingObjects:=False, Contents:=True, Scenarios:=True
End Sub