Hi,
trying to build VBA code to change legend(s) color after changes in worksheet.
I have made following code but I received error - Run-time error '438' Object doesn't support this property or method.
By pressing debug it shows that there is something wrong with lines With Selection.Border and With Selection.Interior.Color = RBG (255,75,0).
I'm quite lost here, what to do?
trying to build VBA code to change legend(s) color after changes in worksheet.
I have made following code but I received error - Run-time error '438' Object doesn't support this property or method.
By pressing debug it shows that there is something wrong with lines With Selection.Border and With Selection.Interior.Color = RBG (255,75,0).
I'm quite lost here, what to do?
Code:
ActiveSheet.ChartObjects("Chart 1").Activate
'On Error Resume Next
ActiveChart.Legend.LegendEntries(1).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(255, 75, 0)
End With
ActiveChart.Legend.LegendEntries(2).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(255, 130, 0)
End With
ActiveChart.Legend.LegendEntries(3).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(255, 180, 0)
End With
ActiveChart.Legend.LegendEntries(4).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(236, 52, 0)
End With
ActiveChart.Legend.LegendEntries(5).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(140, 45, 140)
End With
ActiveChart.Legend.LegendEntries(6).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(77, 196, 17)
End With
ActiveChart.Legend.LegendEntries(7).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(0, 178, 221)
End With
ActiveChart.Legend.LegendEntries(8).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(230, 230, 230)
End With
ActiveChart.Legend.LegendEntries(9).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(200, 198, 196)
End With
ActiveChart.Legend.LegendEntries(10).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(162, 162, 162)
End With
ActiveChart.Legend.LegendEntries(11).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(128, 128, 128)
End With
ActiveChart.Legend.LegendEntries(12).Select
With Selection.Border
.ColorIndex = 2
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False
With Selection.Interior.Color = RGB(102, 102, 102)
End With
End Sub