noname91
06-27-2018, 02:26 AM
Hello all,
I'd just like to quickly ask how one can refer to grouped objects, both in general and for charts in particular, in VBA?
I have the following for referring to single charts:
Sub Picture1_Click()
ActiveSheet.ChartObjects("Chart 6").Visible = True
ActiveSheet.ChartObjects("Chart 9").Visible = True
ActiveSheet.ChartObjects("Chart 7").Visible = False
ActiveSheet.ChartObjects("Chart 8").Visible = False
End Sub
Private Sub CommandButton2_Click()
ActiveSheet.ChartObjects("Chart 6").Visible = False
ActiveSheet.ChartObjects("Chart 9").Visible = False
ActiveSheet.ChartObjects("Chart 7").Visible = True
ActiveSheet.ChartObjects("Chart 8").Visible = True
End Sub
Now this obviously looks tedious but grouping them should help make it more easier to manage. But I can't seem to find the appropriate function for a group of charts anywhere online. I have tried a few combinations including ChartGroups (with the Group name in the brackets) and GroupItems, but each time I keep getting the following error message:
"Object doesn't support this property or method"
Any help would be appreciated. Thanks!
I'd just like to quickly ask how one can refer to grouped objects, both in general and for charts in particular, in VBA?
I have the following for referring to single charts:
Sub Picture1_Click()
ActiveSheet.ChartObjects("Chart 6").Visible = True
ActiveSheet.ChartObjects("Chart 9").Visible = True
ActiveSheet.ChartObjects("Chart 7").Visible = False
ActiveSheet.ChartObjects("Chart 8").Visible = False
End Sub
Private Sub CommandButton2_Click()
ActiveSheet.ChartObjects("Chart 6").Visible = False
ActiveSheet.ChartObjects("Chart 9").Visible = False
ActiveSheet.ChartObjects("Chart 7").Visible = True
ActiveSheet.ChartObjects("Chart 8").Visible = True
End Sub
Now this obviously looks tedious but grouping them should help make it more easier to manage. But I can't seem to find the appropriate function for a group of charts anywhere online. I have tried a few combinations including ChartGroups (with the Group name in the brackets) and GroupItems, but each time I keep getting the following error message:
"Object doesn't support this property or method"
Any help would be appreciated. Thanks!