+ Reply to Thread
Results 1 to 12 of 12

hide or unhide rows with button

Hybrid View

  1. #1
    Bea
    Guest

    hide or unhide rows with button

    I want to group rows together and have a quick expand/collapse button on the
    sheet itself. I see the group/outline function but do not like the display of
    the expand/collapse in the left side of the rows.

  2. #2
    Dave Peterson
    Guest

    Re: hide or unhide rows with button

    You could put a button from the control toolbox toolbar on that worksheet.
    Double click on that button and you'll see where the code goes.

    Paste this in that window and end up with something that looks like this.

    Option Explicit
    Private Sub CommandButton1_Click()
    Dim myRng As Range

    Set myRng = Me.Range("a3:a5,a7:a19,a22:a33")

    myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)

    End Sub

    Adjust the range you want to hide/show

    If you're new to macros, you may want to read David McRitchie's intro at:
    http://www.mvps.org/dmcritchie/excel/getstarted.htm


    Bea wrote:
    >
    > I want to group rows together and have a quick expand/collapse button on the
    > sheet itself. I see the group/outline function but do not like the display of
    > the expand/collapse in the left side of the rows.


    --

    Dave Peterson

  3. #3
    Bea
    Guest

    Re: hide or unhide rows with button

    This was perfect Dave! Thank you so much!

    "Dave Peterson" wrote:

    > You could put a button from the control toolbox toolbar on that worksheet.
    > Double click on that button and you'll see where the code goes.
    >
    > Paste this in that window and end up with something that looks like this.
    >
    > Option Explicit
    > Private Sub CommandButton1_Click()
    > Dim myRng As Range
    >
    > Set myRng = Me.Range("a3:a5,a7:a19,a22:a33")
    >
    > myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
    >
    > End Sub
    >
    > Adjust the range you want to hide/show
    >
    > If you're new to macros, you may want to read David McRitchie's intro at:
    > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >
    >
    > Bea wrote:
    > >
    > > I want to group rows together and have a quick expand/collapse button on the
    > > sheet itself. I see the group/outline function but do not like the display of
    > > the expand/collapse in the left side of the rows.

    >
    > --
    >
    > Dave Peterson
    >


  4. #4
    Gord Dibben
    Guest

    Re: hide or unhide rows with button

    Bea

    There is also Views>Custom Views if you don't want to go the macro route.


    Gord Dibben Excel MVP

    On Tue, 29 Nov 2005 13:18:06 -0800, Bea <Bea@discussions.microsoft.com> wrote:

    >This was perfect Dave! Thank you so much!
    >
    >"Dave Peterson" wrote:
    >
    >> You could put a button from the control toolbox toolbar on that worksheet.
    >> Double click on that button and you'll see where the code goes.
    >>
    >> Paste this in that window and end up with something that looks like this.
    >>
    >> Option Explicit
    >> Private Sub CommandButton1_Click()
    >> Dim myRng As Range
    >>
    >> Set myRng = Me.Range("a3:a5,a7:a19,a22:a33")
    >>
    >> myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
    >>
    >> End Sub
    >>
    >> Adjust the range you want to hide/show
    >>
    >> If you're new to macros, you may want to read David McRitchie's intro at:
    >> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >>
    >>
    >> Bea wrote:
    >> >
    >> > I want to group rows together and have a quick expand/collapse button on the
    >> > sheet itself. I see the group/outline function but do not like the display of
    >> > the expand/collapse in the left side of the rows.

    >>
    >> --
    >>
    >> Dave Peterson
    >>



  5. #5
    Bea
    Guest

    Re: hide or unhide rows with button

    Gord - Thanks for your help. Can you use a button with the Custom Views? I
    could not figure that one out.

    "Gord Dibben" wrote:

    > Bea
    >
    > There is also Views>Custom Views if you don't want to go the macro route.
    >
    >
    > Gord Dibben Excel MVP
    >
    > On Tue, 29 Nov 2005 13:18:06 -0800, Bea <Bea@discussions.microsoft.com> wrote:
    >
    > >This was perfect Dave! Thank you so much!
    > >
    > >"Dave Peterson" wrote:
    > >
    > >> You could put a button from the control toolbox toolbar on that worksheet.
    > >> Double click on that button and you'll see where the code goes.
    > >>
    > >> Paste this in that window and end up with something that looks like this.
    > >>
    > >> Option Explicit
    > >> Private Sub CommandButton1_Click()
    > >> Dim myRng As Range
    > >>
    > >> Set myRng = Me.Range("a3:a5,a7:a19,a22:a33")
    > >>
    > >> myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
    > >>
    > >> End Sub
    > >>
    > >> Adjust the range you want to hide/show
    > >>
    > >> If you're new to macros, you may want to read David McRitchie's intro at:
    > >> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    > >>
    > >>
    > >> Bea wrote:
    > >> >
    > >> > I want to group rows together and have a quick expand/collapse button on the
    > >> > sheet itself. I see the group/outline function but do not like the display of
    > >> > the expand/collapse in the left side of the rows.
    > >>
    > >> --
    > >>
    > >> Dave Peterson
    > >>

    >
    >


  6. #6
    Gord Dibben
    Guest

    Re: hide or unhide rows with button

    Bea

    Not really.

    You can go to Tools>Customize>Commands>View.

    Drag the Custom Views drop-down onto your Toolbar.

    You can choose which view from the drop-down.

    Possible to have many custom views, each with a distinct name like "hidden"
    "unhidden" "group1" etc.


    Gord

    On Tue, 29 Nov 2005 14:01:02 -0800, Bea <Bea@discussions.microsoft.com> wrote:

    >Gord - Thanks for your help. Can you use a button with the Custom Views? I
    >could not figure that one out.
    >
    >"Gord Dibben" wrote:
    >
    >> Bea
    >>
    >> There is also Views>Custom Views if you don't want to go the macro route.
    >>
    >>
    >> Gord Dibben Excel MVP
    >>
    >> On Tue, 29 Nov 2005 13:18:06 -0800, Bea <Bea@discussions.microsoft.com> wrote:
    >>
    >> >This was perfect Dave! Thank you so much!
    >> >
    >> >"Dave Peterson" wrote:
    >> >
    >> >> You could put a button from the control toolbox toolbar on that worksheet.
    >> >> Double click on that button and you'll see where the code goes.
    >> >>
    >> >> Paste this in that window and end up with something that looks like this.
    >> >>
    >> >> Option Explicit
    >> >> Private Sub CommandButton1_Click()
    >> >> Dim myRng As Range
    >> >>
    >> >> Set myRng = Me.Range("a3:a5,a7:a19,a22:a33")
    >> >>
    >> >> myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
    >> >>
    >> >> End Sub
    >> >>
    >> >> Adjust the range you want to hide/show
    >> >>
    >> >> If you're new to macros, you may want to read David McRitchie's intro at:
    >> >> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >> >>
    >> >>
    >> >> Bea wrote:
    >> >> >
    >> >> > I want to group rows together and have a quick expand/collapse button on the
    >> >> > sheet itself. I see the group/outline function but do not like the display of
    >> >> > the expand/collapse in the left side of the rows.
    >> >>
    >> >> --
    >> >>
    >> >> Dave Peterson
    >> >>

    >>
    >>



  7. #7
    Dave Peterson
    Guest

    Re: hide or unhide rows with button

    Sometimes you can just record a macro while you do it manually.

    I got this when I showed the view named Test1.

    Option Explicit
    Sub Macro1()
    ActiveWorkbook.CustomViews("test1").Show
    End Sub


    Behind a commandbutton from the control toolbox toolbar:

    Option Explicit
    Private Sub CommandButton1_Click()
    Me.Parent.CustomViews("test1").Show
    End Sub

    Me is the worksheet that owns the code (and button). Me.Parent is the workbook.

    Bea wrote:
    >
    > Gord - Thanks for your help. Can you use a button with the Custom Views? I
    > could not figure that one out.
    >
    > "Gord Dibben" wrote:
    >
    > > Bea
    > >
    > > There is also Views>Custom Views if you don't want to go the macro route.
    > >
    > >
    > > Gord Dibben Excel MVP
    > >
    > > On Tue, 29 Nov 2005 13:18:06 -0800, Bea <Bea@discussions.microsoft.com> wrote:
    > >
    > > >This was perfect Dave! Thank you so much!
    > > >
    > > >"Dave Peterson" wrote:
    > > >
    > > >> You could put a button from the control toolbox toolbar on that worksheet.
    > > >> Double click on that button and you'll see where the code goes.
    > > >>
    > > >> Paste this in that window and end up with something that looks like this.
    > > >>
    > > >> Option Explicit
    > > >> Private Sub CommandButton1_Click()
    > > >> Dim myRng As Range
    > > >>
    > > >> Set myRng = Me.Range("a3:a5,a7:a19,a22:a33")
    > > >>
    > > >> myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
    > > >>
    > > >> End Sub
    > > >>
    > > >> Adjust the range you want to hide/show
    > > >>
    > > >> If you're new to macros, you may want to read David McRitchie's intro at:
    > > >> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    > > >>
    > > >>
    > > >> Bea wrote:
    > > >> >
    > > >> > I want to group rows together and have a quick expand/collapse button on the
    > > >> > sheet itself. I see the group/outline function but do not like the display of
    > > >> > the expand/collapse in the left side of the rows.
    > > >>
    > > >> --
    > > >>
    > > >> Dave Peterson
    > > >>

    > >
    > >


    --

    Dave Peterson

+ 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