+ Reply to Thread
Results 1 to 4 of 4

Hide/Unhide

Hybrid View

jknober Hide/Unhide 04-22-2010, 04:01 PM
Palmetto Re: Hide/Unhide problem 04-22-2010, 04:34 PM
jknober Re: Hide/Unhide problem 04-26-2010, 04:54 PM
Palmetto Re: Hide/Unhide problem 04-26-2010, 05:06 PM
  1. #1
    Registered User
    Join Date
    06-04-2009
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2007
    Posts
    3

    Hide/Unhide

    Hi
    I am trying to hide some lines that are not needed most of the time. I am trying to make them accessible with the click of a button if they are. Can you tell me what is wrong with the code I am using? I keep getting else with out if and i just do not get it.

    'If Rows("9:11").EntireRow.Hidden = True Then
        Rows("9:11").EntireRow.Hidden = False
       Else
    If Rows("9:11").EntireRow.Hidden = False Then
        Rows("9:11").EntireRow.Hidden = True
    End If
    Last edited by jknober; 04-22-2010 at 04:36 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Hide/Unhide problem

    Please edit your post to comply with the Forum Rules. All VBA code must be wrapped in code tags. After you have applied the code tags, solutions will be suggested.

    Rule #3
    Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button. For more information about these and other tags, click here.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    06-04-2009
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Hide/Unhide problem

    Does anyone know why the code in this is incorrect?

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Hide/Unhide problem

    Each "IF" statement must have its own "End If" (there is one exception to this). You are missing the second End If line of code.

    However, all you need is:
    Sub Toggle_Rows()
    
        Rows("9:11").Hidden = Range("A1") = True
    
    End Sub
    Which, if you use a check box from the Forms Controls, set A1 as the linked cell (or choose another cell) and assign this code to the check box, then you only need to "check" the box to hide the row and "uncheck" it to show them.

+ 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