+ Reply to Thread
Results 1 to 5 of 5

hide/unhide row macro

  1. #1
    Registered User
    Join Date
    06-14-2004
    Posts
    5

    hide/unhide row macro

    I'm new to writing macros and need a little help. I'm trying to write a macro that will hide/unhide different rows within a worksheet. For example, I want to check a box and be able to hide rows 8, 10 and 12, but leave rows 9 and 11 alone. Thanks in advance for your help!

  2. #2
    Dave Peterson
    Guest

    Re: hide/unhide row macro

    Put a checkbox from the forms toolbar (not the control toolbox toolbar) on a
    worksheet.

    Assign it this macro:

    Option Explicit
    Sub testme()

    Dim myRng As Range
    Dim myCBX As CheckBox

    Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)

    Set myRng = ActiveSheet.Range("a8,a10,a12")

    ' If myCBX.Value = xlOn Then
    ' myRng.EntireRow.Hidden = True
    ' Else
    ' myRng.EntireRow.Hidden = False
    ' End If

    myRng.EntireRow.Hidden = myCBX.Value

    End Sub

    The commented lines may be easier to understand, but they're equivalent to the
    last line.

    Checkman wrote:
    >
    > I'm new to writing macros and need a little help. I'm trying to write a
    > macro that will hide/unhide different rows within a worksheet. For
    > example, I want to check a box and be able to hide rows 8, 10 and 12,
    > but leave rows 9 and 11 alone. Thanks in advance for your help!
    >
    > --
    > Checkman
    > ------------------------------------------------------------------------
    > Checkman's Profile: http://www.excelforum.com/member.php...o&userid=10620
    > View this thread: http://www.excelforum.com/showthread...hreadid=503463


    --

    Dave Peterson

  3. #3
    Don Guillett
    Guest

    Re: hide/unhide row macro

    try
    Sub ToggleHideColumns()

    'Range("a1,c1,g1").EntireColumn.Hidden = Not
    Range("a1,c1,g1").EntireColumn.Hidden
    Range("a2,a4,a8").EntireRow.Hidden = Not Range("a2,a4,a8").EntireRow.Hidden
    End Sub

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Checkman" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I'm new to writing macros and need a little help. I'm trying to write a
    > macro that will hide/unhide different rows within a worksheet. For
    > example, I want to check a box and be able to hide rows 8, 10 and 12,
    > but leave rows 9 and 11 alone. Thanks in advance for your help!
    >
    >
    > --
    > Checkman
    > ------------------------------------------------------------------------
    > Checkman's Profile:
    > http://www.excelforum.com/member.php...o&userid=10620
    > View this thread: http://www.excelforum.com/showthread...hreadid=503463
    >




  4. #4
    Registered User
    Join Date
    06-14-2004
    Posts
    5
    Thanks Dave and Don!

  5. #5
    Don Guillett
    Guest

    Re: hide/unhide row macro

    glad to help. you may have to correct the word wrap if you want to use the
    column one

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Checkman" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Thanks Dave and Don!
    >
    >
    > --
    > Checkman
    > ------------------------------------------------------------------------
    > Checkman's Profile:
    > http://www.excelforum.com/member.php...o&userid=10620
    > View this thread: http://www.excelforum.com/showthread...hreadid=503463
    >




+ 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