problem using VBA to fill color of xy scatter points...

kaydoerr

New Member
Joined
Aug 14, 2012
Messages
2
I'm working on a macro that will format a chart so that it will look the same as all of my other charts.
Getting the code set up for my XY Scatter charts has been causing problems. I've been recording keystrokes and then building the code from there. The issue I'm working on right now is this sliver of code

Code:
Sub FillScatterPoints()
ActiveChart.SeriesCollection(1).Select
With Selection.Format.Fill.Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Transparency = 0
        .Solid
End With
End Sub

This should be turning my scatter points black, but instead it they turn that Excel 2010 blue color which seems to maybe be a default? I've tried numerous variations...

A simpler version without the With statement
Code:
ActiveChart.SeriesCollection(1).Format.Fill.ForeColor.RGB = RGB(0, 0, 0)
ActiveChart.SeriesCollection(1).Format.Fill..Solid
Still got the same result. Also tried this line instead of the .ForeColor.RGB line
Code:
        .ForeColor.ObjectThemeColor = msoThemeColorText1
....which also turns the points to the blue and also tried
Code:
        .BackgroundColor.RGB = RGB(0, 0, 0)
...which bugs. There has to be a simple answer here. Anyone have any ideas? I've been struggling so much with this that I set it up as its own sub and I'm running only this sub on the chart, so it can't be a problem in the rest of the macro. I've written more complicated code than this, so it is especially aggravating that it seems like such a simple task.
Thanks!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Never mind, problem solved!

In case anyone else has a similar problem, it seems like the ".Solid" line is what was changing my points to the default color. So I moved that line BEFORE my ForeColor.RGB line and problem solved! Solid black data points!
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top