+ Reply to Thread
Results 1 to 7 of 7

Through a command button hiding rows

  1. #1
    Registered User
    Join Date
    12-07-2004
    Posts
    18

    Through a command button hiding rows

    Help!
    I am creating a workbook where in worksheet1 there is a checklist. Ideally when a topic's checkbox is clicked, a macro (which I have assigned) will hide certain rows on worksheet2.
    However I cannot get the action to reverse when the box is unchecked.
    This is really frustrating me as I have tried to write a program using boolean instead of the macro for when the button is "clicked" and then clicked again, but I am not getting anywhere.

    If it helps the rows I have also grouped into arrays.

    Below is like my 20th attempt

    Private Sub CheckBox1_Click()
    Sheets("Sheet1").Select
    i = Rows("13:22")
    i.Select
    Selection.EntireRow.Hidden = True
    Sheets("Sheet2").Select

    End Sub

  2. #2
    Ardus Petus
    Guest

    Re: Through a command button hiding rows

    Private Sub CheckBox1_Click()
    Worksheets("Sheet1").Rows("13:22").hidden = True
    End Sub

    HTH
    --
    AP

    "Saz" <[email protected]> a écrit dans le
    message de news: [email protected]...
    >
    > Help!
    > I am creating a workbook where in worksheet1 there is a checklist.
    > Ideally when a topic's checkbox is clicked, a macro (which I have
    > assigned) will hide certain rows on worksheet2.
    > However I cannot get the action to reverse when the box is unchecked.
    > This is really frustrating me as I have tried to write a program using
    > boolean instead of the macro for when the button is "clicked" and then
    > clicked again, but I am not getting anywhere.
    >
    > If it helps the rows I have also grouped into arrays.
    >
    > Below is like my 20th attempt
    >
    > Private Sub CheckBox1_Click()
    > Sheets("Sheet1").Select
    > i = Rows("13:22")
    > i.Select
    > Selection.EntireRow.Hidden = True
    > Sheets("Sheet2").Select
    >
    > End Sub
    >
    >
    > --
    > Saz
    > ------------------------------------------------------------------------
    > Saz's Profile:
    > http://www.excelforum.com/member.php...o&userid=17226
    > View this thread: http://www.excelforum.com/showthread...hreadid=549468
    >




  3. #3
    Tom Ogilvy
    Guest

    RE: Through a command button hiding rows

    If you want them hidden when the checkbox is checked and unhidden when it is
    unchecked then

    Private Sub CheckBox1_Click()
    Set rng = Sheets("Sheet1").Rows("13:22")
    rng.Hidden = CheckBox1.Value
    End Sub

    for the opposite:


    Private Sub CheckBox1_Click()
    Set rng = Sheets("Sheet1").Rows("13:22")
    rng.Hidden = Not CheckBox1.Value
    End Sub

    --
    Regards,
    Tom Ogilvy





    "Saz" wrote:

    >
    > Help!
    > I am creating a workbook where in worksheet1 there is a checklist.
    > Ideally when a topic's checkbox is clicked, a macro (which I have
    > assigned) will hide certain rows on worksheet2.
    > However I cannot get the action to reverse when the box is unchecked.
    > This is really frustrating me as I have tried to write a program using
    > boolean instead of the macro for when the button is "clicked" and then
    > clicked again, but I am not getting anywhere.
    >
    > If it helps the rows I have also grouped into arrays.
    >
    > Below is like my 20th attempt
    >
    > Private Sub CheckBox1_Click()
    > Sheets("Sheet1").Select
    > i = Rows("13:22")
    > i.Select
    > Selection.EntireRow.Hidden = True
    > Sheets("Sheet2").Select
    >
    > End Sub
    >
    >
    > --
    > Saz
    > ------------------------------------------------------------------------
    > Saz's Profile: http://www.excelforum.com/member.php...o&userid=17226
    > View this thread: http://www.excelforum.com/showthread...hreadid=549468
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: Through a command button hiding rows

    Private Sub CheckBox1_Click()
    WorkSheets("Sheet1").Rows("13:22").Hidden = CheckBox1.Value
    End Sub

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Ardus Petus" <[email protected]> wrote in message
    news:[email protected]...
    > Private Sub CheckBox1_Click()
    > Worksheets("Sheet1").Rows("13:22").hidden = True
    > End Sub
    >
    > HTH
    > --
    > AP
    >
    > "Saz" <[email protected]> a écrit dans le
    > message de news: [email protected]...
    > >
    > > Help!
    > > I am creating a workbook where in worksheet1 there is a checklist.
    > > Ideally when a topic's checkbox is clicked, a macro (which I have
    > > assigned) will hide certain rows on worksheet2.
    > > However I cannot get the action to reverse when the box is unchecked.
    > > This is really frustrating me as I have tried to write a program using
    > > boolean instead of the macro for when the button is "clicked" and then
    > > clicked again, but I am not getting anywhere.
    > >
    > > If it helps the rows I have also grouped into arrays.
    > >
    > > Below is like my 20th attempt
    > >
    > > Private Sub CheckBox1_Click()
    > > Sheets("Sheet1").Select
    > > i = Rows("13:22")
    > > i.Select
    > > Selection.EntireRow.Hidden = True
    > > Sheets("Sheet2").Select
    > >
    > > End Sub
    > >
    > >
    > > --
    > > Saz
    > > ------------------------------------------------------------------------
    > > Saz's Profile:
    > > http://www.excelforum.com/member.php...o&userid=17226
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=549468
    > >

    >
    >




  5. #5
    Registered User
    Join Date
    12-07-2004
    Posts
    18

    Ambigious error

    Tom I have tried yours but it will not allow both together as an error occurs stating ambigious error detected as CheckBox1_Click is already being used. I want to use both of your programs that you have created for the checkbox. Do you know how?

    Thanks

    Quote Originally Posted by Tom Ogilvy
    If you want them hidden when the checkbox is checked and unhidden when it is
    unchecked then

    Private Sub CheckBox1_Click()
    Set rng = Sheets("Sheet1").Rows("13:22")
    rng.Hidden = CheckBox1.Value
    End Sub

    for the opposite:


    Private Sub CheckBox1_Click()
    Set rng = Sheets("Sheet1").Rows("13:22")
    rng.Hidden = Not CheckBox1.Value
    End Sub

    --
    Regards,
    Tom Ogilvy





    "Saz" wrote:

    >
    > Help!
    > I am creating a workbook where in worksheet1 there is a checklist.
    > Ideally when a topic's checkbox is clicked, a macro (which I have
    > assigned) will hide certain rows on worksheet2.
    > However I cannot get the action to reverse when the box is unchecked.
    > This is really frustrating me as I have tried to write a program using
    > boolean instead of the macro for when the button is "clicked" and then
    > clicked again, but I am not getting anywhere.
    >
    > If it helps the rows I have also grouped into arrays.
    >
    > Below is like my 20th attempt
    >
    > Private Sub CheckBox1_Click()
    > Sheets("Sheet1").Select
    > i = Rows("13:22")
    > i.Select
    > Selection.EntireRow.Hidden = True
    > Sheets("Sheet2").Select
    >
    > End Sub
    >
    >
    > --
    > Saz
    > ------------------------------------------------------------------------
    > Saz's Profile: http://www.excelforum.com/member.php...o&userid=17226
    > View this thread: http://www.excelforum.com/showthread...hreadid=549468
    >
    >

  6. #6
    Tom Ogilvy
    Guest

    Re: Through a command button hiding rows

    I don't think you understand the code. Either want them hidden when it is
    checked or you want them unhidden when it is checked. Both codes will handle
    both checking and unchecking. The first hides them when it is checked and
    unhides them when it is unchecked - both actions trigger the click event.
    The second does the opposite - so you only need one.

    --
    Regards,
    Tom Ogilvy


    "Saz" wrote:

    >
    > Tom I have tried yours but it will not allow both together as an error
    > occurs stating ambigious error detected as CheckBox1_Click is already
    > being used. I want to use both of your programs that you have created
    > for the checkbox. Do you know how?
    >
    > Thanks
    >
    > Tom Ogilvy Wrote:
    > > If you want them hidden when the checkbox is checked and unhidden when
    > > it is
    > > unchecked then
    > >
    > > Private Sub CheckBox1_Click()
    > > Set rng = Sheets("Sheet1").Rows("13:22")
    > > rng.Hidden = CheckBox1.Value
    > > End Sub
    > >
    > > for the opposite:
    > >
    > >
    > > Private Sub CheckBox1_Click()
    > > Set rng = Sheets("Sheet1").Rows("13:22")
    > > rng.Hidden = Not CheckBox1.Value
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > >
    > >
    > >
    > > "Saz" wrote:
    > >
    > > >
    > > > Help!
    > > > I am creating a workbook where in worksheet1 there is a checklist.
    > > > Ideally when a topic's checkbox is clicked, a macro (which I have
    > > > assigned) will hide certain rows on worksheet2.
    > > > However I cannot get the action to reverse when the box is

    > > unchecked.
    > > > This is really frustrating me as I have tried to write a program

    > > using
    > > > boolean instead of the macro for when the button is "clicked" and

    > > then
    > > > clicked again, but I am not getting anywhere.
    > > >
    > > > If it helps the rows I have also grouped into arrays.
    > > >
    > > > Below is like my 20th attempt
    > > >
    > > > Private Sub CheckBox1_Click()
    > > > Sheets("Sheet1").Select
    > > > i = Rows("13:22")
    > > > i.Select
    > > > Selection.EntireRow.Hidden = True
    > > > Sheets("Sheet2").Select
    > > >
    > > > End Sub
    > > >
    > > >
    > > > --
    > > > Saz
    > > >

    > > ------------------------------------------------------------------------
    > > > Saz's Profile:

    > > http://www.excelforum.com/member.php...o&userid=17226
    > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=549468
    > > >
    > > >

    >
    >
    > --
    > Saz
    > ------------------------------------------------------------------------
    > Saz's Profile: http://www.excelforum.com/member.php...o&userid=17226
    > View this thread: http://www.excelforum.com/showthread...hreadid=549468
    >
    >


  7. #7
    Registered User
    Join Date
    12-07-2004
    Posts
    18

    Tom thanks

    I used yours and at first tried to use both programs you provided at the same time, but found that the first one on its own worked perfectly!

    Cheers Honey!

+ 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