+ Reply to Thread
Results 1 to 23 of 23

hide rows with macro/togglebutton

Hybrid View

  1. #1
    Registered User
    Join Date
    02-03-2005
    Posts
    44

    hide rows with macro/togglebutton

    hello,

    I want to be able to hide and unhide rows by clicking a togglebutton.

    So far, I managed to record 2 macro's. 1 to hide the rows and 1 to unhide the rows. I could make to button's to assign each macro to, but that would be a lot of work, since I want to add this function to several places in my worksheet.

    A togglebutton would do the trick, but I do not know how to assign the 2 macro's to it. Is there any pro out there who could help me out ?

    At least I think the toggle button would be in my humble opinion the best solution. The only thing is that I have to put the togglebutton somewhere outside the rows I wish to hide/unhide. If there is a better solution thinkable I am happy to hear ?

    Next to this, I protect my sheets. With the 2 button's I managed to fix myself I get a 'false' error when I protect my sheet. I am not sure what I am doing wrong?

  2. #2
    Bob Phillips
    Guest

    Re: hide rows with macro/togglebutton

    You don't need a toggle button, just a command button. Just use code like

    Rows("10:12").Hidden = Not Rows("10:12").Hidden

    --
    HTH

    Bob Phillips

    "huntermcg" <[email protected]> wrote
    in message news:[email protected]...
    >
    > hello,
    >
    > I want to be able to hide and unhide rows by clicking a togglebutton.
    >
    > So far, I managed to record 2 macro's. 1 to hide the rows and 1 to
    > unhide the rows. I could make to button's to assign each macro to, but
    > that would be a lot of work, since I want to add this function to
    > several places in my worksheet.
    >
    > A togglebutton would do the trick, but I do not know how to assign the
    > 2 macro's to it. Is there any pro out there who could help me out ?
    >
    > At least I think the toggle button would be in my humble opinion the
    > best solution. The only thing is that I have to put the togglebutton
    > somewhere outside the rows I wish to hide/unhide. If there is a better
    > solution thinkable I am happy to hear ?
    >
    > Next to this, I protect my sheets. With the 2 button's I managed to fix
    > myself I get a 'false' error when I protect my sheet. I am not sure what
    > I am doing wrong?
    >
    >
    > --
    > huntermcg
    > ------------------------------------------------------------------------
    > huntermcg's Profile:

    http://www.excelforum.com/member.php...o&userid=19391
    > View this thread: http://www.excelforum.com/showthread...hreadid=469683
    >




  3. #3
    Registered User
    Join Date
    02-03-2005
    Posts
    44
    great. this works!

    now I still only have one problem. when I want to protect my sheet I get an error that he cannot execute the macro. Do you know what this is, and how to solve it?

  4. #4
    Registered User
    Join Date
    02-03-2005
    Posts
    44
    ... addition to former reply post:

    it is a Run-time error '1004':

    this is my code.

    Sub Macro1()
    Rows("4:20").Hidden = Not Rows("4:20").Hidden
    End Sub
    Sub Macro2()
    Rows("22:39").Hidden = Not Rows("22:39").Hidden
    End Sub
    Sub Macro3()
    Rows("40:54").Hidden = Not Rows("40:54").Hidden
    End Sub
    Sub Macro4()
    Rows("55:68").Hidden = Not Rows("55:68").Hidden
    End Sub

    maybe this helps ...

  5. #5
    Bob Phillips
    Guest

    Re: hide rows with macro/togglebutton

    unprotect the sheet just prior to the code, then protect it after.

    --
    HTH

    Bob Phillips

    "huntermcg" <[email protected]> wrote
    in message news:[email protected]...
    >
    > .. addition to former reply post:
    >
    > it is a Run-time error '1004':
    >
    > this is my code.
    >
    > Sub Macro1()
    > Rows("4:20").Hidden = Not Rows("4:20").Hidden
    > End Sub
    > Sub Macro2()
    > Rows("22:39").Hidden = Not Rows("22:39").Hidden
    > End Sub
    > Sub Macro3()
    > Rows("40:54").Hidden = Not Rows("40:54").Hidden
    > End Sub
    > Sub Macro4()
    > Rows("55:68").Hidden = Not Rows("55:68").Hidden
    > End Sub
    >
    > maybe this helps ...
    >
    >
    > --
    > huntermcg
    > ------------------------------------------------------------------------
    > huntermcg's Profile:

    http://www.excelforum.com/member.php...o&userid=19391
    > View this thread: http://www.excelforum.com/showthread...hreadid=469683
    >




  6. #6
    Registered User
    Join Date
    02-03-2005
    Posts
    44
    I do not understand. I did that.

    I had to unprotect the sheet to make the code/macro work.

+ 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