+ Reply to Thread
Results 1 to 4 of 4

VBA buttons for hide/unhide rows disappear at random

Hybrid View

derekopswat VBA buttons for hide/unhide... 03-29-2013, 06:39 PM
Mallycat Re: VBA buttons for... 03-29-2013, 06:45 PM
derekopswat Re: VBA buttons for... 03-29-2013, 06:47 PM
derekopswat Re: VBA buttons for... 04-01-2013, 01:10 PM
  1. #1
    Registered User
    Join Date
    03-28-2013
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    16

    VBA buttons for hide/unhide rows disappear at random

    Hi -

    I have 5 buttons in my spreadsheet. Each of the 5 buttons expands/contracts a few rows below it. Each button has a separate macro to control it, since each button corresponds to a different set of rows. Here is the code I used (found from another thread). Unfortunately I can't attach the confidential document:

    Sub Packages()
    With Rows("42:50")
            .Select
           .EntireRow.Hidden = Not .EntireRow.Hidden
        End With
    End Sub
    After I click a couple of buttons in the spreadsheet, weird things start to happen. Some buttons will disappear, while others don't, and sometimes the button I'm pressing disappears. Other people have had similar problems and blame it on a bug in Excel 2010, although I haven't found a solution that works for me. It's likely that it is just a bug in Excel because the buttons appear/disappear at random in different patterns.

    Does anyone know of a viable workaround for this? One possibility I could imagine is code that tells the button to always remain visible? I am new to using macros, so I would be thankful for anything to point me in the right direction. Thanks!
    Last edited by derekopswat; 04-01-2013 at 12:31 PM. Reason: incorrect code

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: VBA buttons for hide/unhide rows disappear at random

    From what I can see, the code you posted doesn't hide or show rows. Do you have other code in your sheet? Are the buttons physically placed in the rows that are hidden?

  3. #3
    Registered User
    Join Date
    03-28-2013
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: VBA buttons for hide/unhide rows disappear at random

    Sorry about that. I edited the first post to include the correct code.

    To answer your question: no, the buttons are all in rows that are unaffected by the macro. Their disappearance seems random. Regardless of which button is clicked, sometimes they all disappear, sometimes just a few disappear, and sometimes none disappear.

    There is other code in the document, but I have the same problem whether or not I use this other macro. I'm using a ThisWorkbook macro to protect the document because hide/unhide rows will not work with Excel's built-in protection. Here's the code I use for this:

    Private Sub Workbook_Open()
    With Worksheets("Sheet1")
           .Protect Password:="password", Userinterfaceonly:=True
           .EnableOutlining = True
    End With
    End Sub

    Also, I should mention that I'm not interested in a patch to fix my copy of Excel. This document is meant to go to several people, and I can't expect all of them to repair their software as well.
    Last edited by derekopswat; 04-01-2013 at 12:44 PM.

  4. #4
    Registered User
    Join Date
    03-28-2013
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: VBA buttons for hide/unhide rows disappear at random

    I made a modified version of the document, which is attached. There should be buttons at rows 22, 41, 51, 57, and 75 (sometimes the buttons are invisible when you open the document). To make them disappear, click on a few different buttons 10 times or so. If you have a different version of Excel than I have (2010 Professional), it might work fine for you.

    Thanks. Hope this helps!
    Attached Files Attached Files

+ 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