How to reference to a number/a group of chartobjects?

  • Thread starter Thread starter Gunnar Johansson
  • Start date Start date
G

Gunnar Johansson

Hi,

I have several chartobjects - embedded charts - in a worksheet and want with
some buttons be able to choose which ones of these to hide and to show. They
are named individually already, but I want to be able to refere to a group
of them to be hidden/visible.

When I recorded an naming procedure I got an R1C1 syntax I didn't like and I
don't know how to convert it:
ActiveWorkbook.Names.Add Name:="slask", RefersToR1C1:= _
"=""R_Q_FB_31,R_ROI_FB_31,R_CF_FB_31"""

Instead I tried to define them as sopm kind of index, but isn't skilled
enough to continue with that.:
sr = Blad102.ChartObjects(R_Q_FB_31, R_ROI_FB_31, R_CF_FB_31).ShapeRange

Maybe it should be as some kind of array, but how? Arrays aren't mentioned
as an object to "Name" in "Help".

/Kind regards
 
Hi Gunnar -

Are R_Q_FB_31, R_ROI_FB_31, and R_CF_FB_31 the names of chart objects in the
worksheet? You can show and hide chartobjects by changing the visible property
between true and false. You can do one at a time, all at a time, or some at a time
using an array:

activesheet.chartobjects("R_Q_FB_31").visible=true
activesheet.chartobjects.visible=false
activesheet.chartobjects(array("R_Q_FB_31","R_ROI_FB_31","R_CF_FB_31")).visible=true

I think I'd name each button after its associated chart ("Button R_Q_FB_31"), then
assign each to a macro that toggles the visible property of the chart:

Sub ButtonClicker()
ActiveSheet.ChartObjects(Mid(Application.Caller, 8)).Visible = _
Not ActiveSheet.ChartObjects(Mid(Application.Caller, 8)).Visible
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
YES,

Right on the spot. Your syntax got me in focus of the syntax that I had to
have a single chartobject in index OR an array of more. I tried over and
over again with more than one object ...

/Regards
 
Back
Top