• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Select and modify shapes starting with same name

Vivek D

Member
I have a setup like the one shown below in a dashboard.
On clicking each of the buttons in the top menu, the corresponding columns can be hidden or made visible.

Shapes.png

The buttons(shapes) change color to grey when column is hidden and blue when it is visible.

What I am trying to do now is to enable hiding of the entire section when the title of the section in the top menu is clicked e.g. when Revenue is clicked the entire revenue section in the table below will be hidden but where I'm stuck is how to get all buttons in that section to change color to grey when the title is clicked.
e.g. in the below screen show, all the buttons under Revenue should have been grey.

Shapes2.png

Because of how all my shapes are grouped (multiple levels), I am not able to select all the shapes based on group names so need some way to select all shapes based on the starting part of their names and change the shapes colors based on that.

Note: I need kind of a reusable procedure to do this as I have a number of such menu items. What I have shown and provided in the sample excel is just a sample.
 

Attachments

  • Shapes.xlsm
    26.2 KB · Views: 1
@Vivek D
Something like this?
I gotta break some or 'groups', You can set those back if really need and still works after that.
Also, I changed two properties of groups; 'Don't move or size with cells'
 

Attachments

  • Shapes.xlsm
    27.2 KB · Views: 3
Actually, the groups that I had are further grouped into a single group. I have several such groups in the dashboard. I've modified the file you sent to include the additional grouping. With this additional grouping your code fails and that is where I was having a problem as well.

Basically, it looks like if I have 3 levels of groups then the middle level group is not recognized.
 

Attachments

  • Shapes2.xlsm
    26.2 KB · Views: 3
@Vivek D
This is the key for grouping all 'button' to work same time
if You'll click the wide one.
Code:
    If shape = "Base Revenue" Then shape = "Base Revenue Group"
    If shape = "Base GM" Then shape = "Base GM Group"
So far this version is the best that I offer now.
I add few more code lines and I changed back some properties.
 

Attachments

  • Shapes.xlsm
    27.7 KB · Views: 2
Not sure if you saw my 2nd file, but the actual hierarchy I have is as shown below. Like "Base Group" there are 3 other groups too with each having 3 levels in my dashboard.

Shapes Heirarchy.png

With such a structure ActiveSheet.Shapes("Base GM Group") results in a error "The item with the specified name wasn't found".

If I remove the top level grouping called "Base Group" then it works but I need that grouping for other purposes.

So my problem still is... how do I select the "Base GM Group" without changing the structure or how do I select all Shapes that have a name starting with "Base GM".
 
@Vivek D
I saw those groups ...
I've still one 'idea' ... not good but this works ON/OFF.
but You will have still work with it,
''Don't move or size with cells'-case
 

Attachments

  • Shapes2.xlsm
    30 KB · Views: 3
Yeah. Putting each shape name into the code would be too much because I have close 70-80 options/shapes in the original dashboard.
I also don't want so many hard coded values in the code. That's why I'm looking for some simple/generic piece of code to do this.
 
Back
Top