Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Charts3()
- ' This sub shows some other things you can do to
- ' fine tune charts. In general, you learn some of the
- ' coding from recording, some from the Object Browser.
- Dim red1 As Integer, green1 As Integer, blue1 As Integer
- Dim red2 As Integer, green2 As Integer, blue2 As Integer
- Dim chtObj As ChartObject
- Dim cht As Chart
- Dim ser As Series
- Dim ax As Axis
- ' Use this next statement so that the random colors chosen
- ' later on will be different from run to run.
- Randomize
- Set chtObj = wsDistrict12.ChartObjects("District 12")
- Set cht = chtObj.Chart
- With cht
- ' Change properties of plot area.
- With .PlotArea.Format.Fill
- MsgBox "The plot area will be changed from blank to gray."
- .ForeColor.ObjectThemeColor = msoThemeColorBackground1
- .ForeColor.Brightness = -0.150000006
- .Visible = msoTrue
- End With
- MsgBox "It will now be restored to blank."
- .PlotArea.Format.Fill.Visible = msoFalse
- ' Remove and restore grid lines.
- Set ax = .Axes(xlValue)
- With ax.MajorGridlines.Format.Line
- MsgBox "The horizontal grid lines will be deleted."
- .Visible = msoFalse
- MsgBox "They will now be restored."
- .Visible = msoTrue
- End With
- ' Generate two random colors (with no green in the first,
- ' no red in the second).
- MsgBox "The two series will now change to some random colors."
- red1 = Int(Rnd * 255)
- green1 = 0
- blue1 = Int(Rnd * 255)
- red2 = 0
- green2 = Int(Rnd * 255)
- blue2 = Int(Rnd * 255)
- ' Change some colors in the chart.
- Set ser = .SeriesCollection(1)
- With ser
- .Border.Color = RGB(red1, green1, blue1)
- .MarkerBackgroundColor = RGB(red1, green1, blue1)
- .MarkerForegroundColor = RGB(red1, green1, blue1)
- End With
- Set ser = .SeriesCollection(2)
- With ser
- .Border.Color = RGB(red2, green2, blue2)
- .MarkerBackgroundColor = RGB(red2, green2, blue2)
- .MarkerForegroundColor = RGB(red2, green2, blue2)
- End With
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement