Using msoTrue in VBA to change series marker visibility not working properly.

vris92

New Member
Joined
Dec 8, 2016
Messages
3
<form action="https://www.reddit.com/r/excel/comments/5h19fx/using_msotrue_in_vba_to_change_series_marker/#" class="usertext warn-on-unload" id="form-t3_5h19fxqoc" style="margin: 0px; padding: 0px; font-size: small;">I have an Excel 2016 project I am working on and have need of a check box to toggle the visibility of a data series on a chart. The code I have included below works fine to hide the data series when I uncheck the box, but when I check the box again, the fill is not restored. Is there any way that I can affect this through the checkbox interface?


<code style="font-family: 'Courier New', courier, monospace; margin: 0px 2px; padding: 15px; border: 0px; border-radius: 2px; word-break: normal; display: block; font-size: 1em; line-height: 16px; overflow: auto; background-color: transparent;">Sub CheckBox17_Click()
Dim boxvalue As Long
boxvalue = Worksheets("Test View").Shapes("Check Box 17").ControlFormat.Value
If boxvalue = 1 Then
Worksheets("Test View").ChartObjects("Chart 2").Chart.FullSeriesCollection(2).Select
Selection.Format.Fill.Visible = msoTrue
Else
Worksheets("Test View").ChartObjects("Chart 2").Chart.FullSeriesCollection(2).Select
Selection.Format.Fill.Visible = msoFalse
End If
End Sub
</code>



</form>

Thanks for any insight you might have guys.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi welcome to forum.

Just a guess but try replacing msoTrue with msoCTrue & see if that helps you.

Dave
 
Upvote 0
Hi Dave, thanks. Unfortunately that doesn't seem to change anything :( It still turns off fill just fine with msoCFalse instead of msoFalse, but it won't turn it back on. For the life of me I can't figure out what the difference could possibly be.
 
Upvote 0
Don't think msoTristate has msoCFalse just msoFalse which has a value of 0.

msoTrue has value of -1 whilst msoCTrue has value of 1.

Not sure why does not work for you perhaps another here may be able to offer some insight.

dave
 
Upvote 0
fwiw I used a workaround to achieve the desired effect. I filtered the data using .IsFiltered = True/False on the series I wished to hide or show. There is some loss of functionality as part of the reason I wanted to be able to hide the data was to more clearly see the trend line (which obviously disappears when the series is filtered). Hiding both is still good enough for now as trendline clarification is secondary to toggling series. Thanks for trying, anyway.
 
Upvote 0
Try this....Its a start and I believe you can tailor to your application.

How to Hide and Unhide Rows/Objects

Sub ItemDetails_Show()

With Sheet2

Range("9:13").EntireRow.Hidden = False (or you can put Range/Shape(“xxx”).visible/hidden=False

.Shapes("ViewDetBtn").Visible = msoFalse

.Shapes("HideDetBtn").Visible = msoCTrue

End With

End Sub

Sub ItemDetails_Hide()

With Sheet2

Range("9:13").EntireRow.Hidden = True (See above)

.Shapes("ViewDetBtn").Visible = msoCTrue

.Shapes("HideDetBtn").Visible = msoFalse

End With

End Sub
 
Upvote 0
Couple things.

VBA Code:
boxvalue = Worksheets("Test View").Shapes("Check Box 17").ControlFormat.Value

Yikes! Assign the linked cell of the checkbox, and use the value in the cell.

VBA Code:
msoTrue

Just use True and False.

Now to change visibility of a series with lines and markers, without filtering it out of the chart and removing a trendline:

VBA Code:
' Hide Series
With MySeries
    .Format.Line.Visible = False
    .MarkerStyle = xlMarkerStyleNone
End With

' Show Series
With MySeries
    .Format.Line.Visible = True
    .MarkerStyle = xlMarkerStyleAutomatic
    ' or xlMarkerStyleCircle, or whatever
End With
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

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