Hiding data series in a bubble chart using VBA

kmurshed

New Member
Joined
Aug 14, 2011
Messages
8
Hello,

I'm having some problems when trying to hide and unhide a data series, in a bubble chart, using VBA.

The code I'm using is this, it changes the color of the bubble from white to green, and when its white, it gets hidden:

HTML:
Sheets("overview").ChartObjects("Chart 6").Activate
With ActiveChart.SeriesCollection("high high")
    If .Interior.ColorIndex = -4142 Then
    .Interior.ColorIndex = 2
    .Border.ColorIndex = 2 
    
    Else
    .Interior.ColorIndex = -4142
    .Border.ColorIndex = -4142

    End If
End With
The color does change, and I do get the "hiding" effect, but still there is a thin border line that remains green even after I change the color, and I've tried all sorts of things in order to change its color also, but I can't seem to get it to work.

Could someone help me?

Thanks in advance
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Which version of Excel?
Have a play with:
Code:
With ActiveChart.SeriesCollection("high high")
    'hide:
    .Format.Line.Visible = msoFalse
    .Format.Fill.Visible = msoFalse
    'show:
    .Format.Line.Visible = msoTrue
    .Format.Fill.Visible = msoTrue
End With
and while testing you may need a sprinkling of
activechart.Refresh
to see the changes taking place.
 
Upvote 0
Thanks for your reply.

That's a nice alternative, I thought it would work, but its behaving strangely. When both line and fill are set to msoFalse, I get the green color I have picked for the series, and when they are set to msoTrue, it returns a random color and a thick line. I'm trying now to add some command lines to format the line and the color, see if it works.

BTW, im using Excel 2007

Thanks
 
Upvote 0
I've managed to get the desired effect combining
Code:
.Format.Fill.Visible = msoTrue
.Format.Line.Visible = msoFalse

with

Code:
.Format.Fill.ForeColor.RGB = RGB(255, 255, 255)

but i'm still getting that anoying border line that does not seems to be affected by .format.line statements..
 
Upvote 0
I figure I could make it disappear if there was a way of getting VBA to do the same as if I right clicked on the data series, selected format data series, and set the fill property to "No fill".

Is there a way?
 
Upvote 0
I figured it out using the following code:

Code:
With ActiveChart.SeriesCollection("high high")

    If .Interior.ColorIndex = xlNone Then
        .Interior.ColorIndex = xlSolid
        .Format.Fill.ForeColor.RGB = RGB(84, 234, 64)
    Else
        .Interior.ColorIndex = xlNone
    End If
ActiveChart.Refresh
End With

Thanks for your help, it lead me in the right direction
;)
 
Upvote 0
Thats the weird thing, everything but fill color was set to null, so nothing else was supposed to be there, but thats probably it, maybe I messed with one of those elements configuration while testing..
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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