PDA

View Full Version : chart properties in recording macro



rianz
05-23-2011, 08:06 PM
Hi, im new using vba excel and im using excel 2007.
im create chart using recording macro and here my code:

Private Sub CommandButton1_Click()

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range( _
"'siklus'!$B$2:$B$2709,'siklus'!$C$2:$C$2709,'siklus'!$U$2:$U$2709")
ActiveChart.ChartType = xlLine

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range( _
"'siklus'!$B$2:$B$2709,'siklus'!$D$2:$D$2709,'siklus'!$U$2:$U$2709")
ActiveChart.ChartType = xlLine
.
.
.
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range( _
"'siklus'!$B$2:$B$2709,'siklus'!$T$2:$T$2709,'siklus'!$U$2:$U$2709")
ActiveChart.ChartType = xlLine

End Sub


my question is how to coloring data series,change legend position to bottom.

thx

*Sorry for my bad english...

nepotist
05-24-2011, 08:16 AM
Changing color of the Series line
ActiveChart.SeriesCollection(2).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
End With
For moving the legend:
ActiveChart.Legend.Select
Selection.Left = 320
Selection.Top = 235

rianz
05-24-2011, 07:31 PM
hi nepotist thx for reply

for changing color of the series line i have error message "Object doesn't support this property or method"
and for moving legend no error but i want show the legend in the middle bottom and without overlapping the chart

thx again