|
-
Aug 29th, 2013, 06:57 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Excel VBA - how to remove chart series marker line color
I can easily remove the border of the marker using the Excel menus (Format Data Series, Marker Line Color, No Line) but can't seem to do it using VBA. Using the recorder results in no change at all. I've tried changing .MarkerBackgroundColor = xlNone and that doesn't work either. What am I missing? I've been playing with this way too long and still can't figure it out.
-
Aug 30th, 2013, 07:11 AM
#2
Re: Excel VBA - how to remove chart series marker line color
I don't do a whole lot with charts, but when I create a marker line chart, then do the Format Data Series, Marker Line Color, No Line...I don't see it changing anything as far as I can tell. What is it supposed to be doing? And what version of Excel are you using?
-
Aug 30th, 2013, 11:06 AM
#3
Thread Starter
Fanatic Member
Re: Excel VBA - how to remove chart series marker line color
Excel 2010. Marker line is an outline around the marker. For example, you can have a red fill and a black outline. I want to turn off the outline but can't seem to figure out how to do it w/ VBA. In older versions of Excel it was called marker background color, but things appear to be different in newer excel versions. The odd thing is the macro recorder produces the same code for turning off the line connecting the markers and turning off the marker border (line). Clearly they are different. I'm beginning to think it can't be done via VBA. Disappointing.............
-
Aug 30th, 2013, 12:09 PM
#4
Re: Excel VBA - how to remove chart series marker line color
Might have come up with a "poor man's solution."
This code will make the border the same color as the fill:
Code:
Sub mark3()
Dim ws As Worksheet
Dim cht As ChartObject
Dim ser As Series
Set ws = ActiveSheet
Set cht = ws.ChartObjects(1)
Set ser = cht.Chart.SeriesCollection(1)
ser.MarkerForegroundColor = ser.MarkerBackgroundColor
End Sub
-
Aug 30th, 2013, 12:47 PM
#5
Thread Starter
Fanatic Member
Re: Excel VBA - how to remove chart series marker line color
Thanks, I've already done that. It essentially means the marker is larger than desired. I still want to turn off the marker line. Seems possible looking at the object model, but simply doesn't work.
Any chart power users out there?
-
Aug 30th, 2013, 12:52 PM
#6
Re: Excel VBA - how to remove chart series marker line color
so make the marker size smaller:
ser.MarkerSize = 8
-
Aug 30th, 2013, 01:19 PM
#7
Re: Excel VBA - how to remove chart series marker line color
I believe you have to access "points" rather than just "series" as I previously did:
Code:
Sub mark3()
Dim ws As Worksheet
Dim cht As ChartObject
Dim ser As Series
Dim pts As Points
Dim i As Integer
Set ws = ActiveSheet
Set cht = ws.ChartObjects(1)
Set ser = cht.Chart.SeriesCollection(1)
Set pts = ser.Points
For i = 1 To pts.Count
pts(i).MarkerForegroundColor = xlNone
Next i
End Sub
-
Aug 30th, 2013, 02:57 PM
#8
Thread Starter
Fanatic Member
Re: [RESOLVED] Excel VBA - how to remove chart series marker line color
Actually, I found a way to do it for the entire series instead of point by point. The trick was to use the value -2 (xlHundreds or xlParamTypeBinary) instead of -4142 (xlNone) for the MarkerForegroundColor. I discovered it by turning off the marker line using the excel dialog boxes, then running a macro to tell me the marker foreground color. Also, I'd been fiddling with the wrong item - background color instead of foreground color. Thanks for your inspiration!
What really goofed me up was the macro recorder. It wasn't even close.
Last edited by VBAhack; Aug 30th, 2013 at 04:04 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|