+ Reply to Thread
Results 1 to 23 of 23

Button to toggle visibility of all ovals on active sheet

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Button to toggle visibility of all ovals on active sheet

    Hello,

    I am trying to create a button that will either toggle the visibility of all the ovals on the active sheet, or two buttons that will turn the visibility of the ovals on and off. One of the problems i was encountering was being unable to figure out how to loop through all of the ovals on an active sheet without knowing the range of oval numbers. Any assistance would be greatly appreciated.

    Thank you for your time.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Button to toggle visibility of all ovals on active sheet

    Please Login or Register  to view this content.
    for instance
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    I think I am doing it wrong because I am trying to do it using a macro and applying the macro to the button.

    Please Login or Register  to view this content.
    This does not work. I have little to no experience in visual basic, but I have some experience in C.

    Thanks for the quick reply

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Button to toggle visibility of all ovals on active sheet

    'does not work' means what exactly? error message? nothing happens?

  5. #5
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    run-time error'1004:

    unable to get the visible property of the Ovals class

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Button to toggle visibility of all ovals on active sheet

    do you currently have some hidden and some visible?

  7. #7
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    They are currently all visible.

  8. #8
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    I don't know if this is any help to you but this is what I had before in the macro that worked to toggle the visibility of the ovals.

    Please Login or Register  to view this content.

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Button to toggle visibility of all ovals on active sheet

    weird-seems you can't read the property only set it so you need two buttons
    Please Login or Register  to view this content.
    for one and
    Please Login or Register  to view this content.
    for the other

    edit: or if you want one button you can use a workaround

    Please Login or Register  to view this content.
    because you can read the visibility of a single shape :-)

  10. #10
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    are you saying the entire code should be this?

    Please Login or Register  to view this content.
    If so, I am still getting the error:

    run-time error'1004":

    unable to get the Visible property of the Ovals class



    Additionally does saving it as a macro enabled workbook do anything to affect this?

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Button to toggle visibility of all ovals on active sheet

    no-you have to do that or you'll lose the code ;-)

    I tested that code in both 2010 and 2011 and it worked in both versions

  12. #12
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    Ok I think I solved the first problem. There was an oval that was visible, it was just off the screen... I replaced it with a donut and now I am getting a different error.


    "cannot run the macro "...". The macro may not be available in this workbook or all macros may be disabled."

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Button to toggle visibility of all ovals on active sheet

    try reassigning the macro to the button

  14. #14
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    That was the first thing I tried. You have been a great help so far and I am very appreciative.

    I had another idea. If I wanted to toggle a few specific ovals and not all of them can it simply be done using a modification of:

    Please Login or Register  to view this content.
    in combination with your toggle code:

    Please Login or Register  to view this content.

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Button to toggle visibility of all ovals on active sheet

    that oughta work-does it? ;-)

  16. #16
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    I could not get it to work, but I have a workaround. Thanks for all your help.

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Button to toggle visibility of all ovals on active sheet

    Does this work?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  18. #18
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    It did not work for all ovals but it worked for 1 out of 32.
    Either way I have an alternate solution, thank you though.

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Button to toggle visibility of all ovals on active sheet

    Are some of the ovals grouped?

    If they were the code wouldn't work for them.

  20. #20
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    yes, all of the ovals are grouped with the exception of the one oval that worked with the code.

  21. #21
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Button to toggle visibility of all ovals on active sheet

    Try this, it worked with grouped ovals.
    Please Login or Register  to view this content.

  22. #22
    Registered User
    Join Date
    01-18-2013
    Location
    orlando, florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Button to toggle visibility of all ovals on active sheet

    Did not work for me. Only worked for the one oval that is not grouped.

    Note: my ovals are not grouped with other ovals exclusively, some rectangles that I do not want hidden.

    My problem has been solved but ill keep checking here for simple amusement. I have a solution that works for now. Ideally if you want to spin your wheels in your brain you can try to figure out how to define a type of object so that when you copy and paste that object you can hide all versions of that object that were duplicated.

    If your interested here is my project I was working on and you can see my workaround for yourself.

    http://www.mediafire.com/?pd0aybut9v5ur0b

    The goal is to be able to hide all of the "mortars" even if i make more of them on another sheet. By that I mean I would be able to copy the template and design multiple "bases" on different sheets and be able to press the button on the sheet and hide the desired shapes on the sheet.
    Last edited by apathetic; 01-19-2013 at 12:00 AM.

  23. #23
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Button to toggle visibility of all ovals on active sheet

    I should have said that by 'grouped ovals' I meant groups with ovals only.

    Give this a try, it goes into each group it finds and checks for any ovals.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1