Consulting

Results 1 to 3 of 3

Thread: How do I create a macro that allows me to show and hide rows with only one button?

  1. #1
    VBAX Regular
    Joined
    Jun 2016
    Posts
    29
    Location

    How do I create a macro that allows me to show and hide rows with only one button?

    Hello, I would like to be able to click a button and unhide 10 rows. Then click the same button and have them hide those rows. I have the macro to unhide the rows, I just don't know how to make the same button hide them if they aren't hidden. Can anyone help me with that. My understanding of VBA is extremely limited. Thank you in advance. Here is my macro so far:

    HTML Code:
    Sub MultiYear_Show()
    '
    ' MultiYear_Show Macro
    '
    '
        Rows("10:20").Select
        Selection.EntireRow.Hidden = False
    End Sub

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    give this a go
    Rows("10:20").EntireRow.Hidden = Not Rows("10:20").EntireRow.Hidden

  3. #3
    VBAX Regular
    Joined
    Jun 2016
    Posts
    29
    Location
    Quote Originally Posted by JKwan View Post
    give this a go
    Rows("10:20").EntireRow.Hidden = Not Rows("10:20").EntireRow.Hidden
    It worked! Thank you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •