Consulting

Results 1 to 4 of 4

Thread: How to Hide Specified Cells?

  1. #1
    VBAX Newbie
    Joined
    Dec 2010
    Posts
    4
    Location

    How to Hide Specified Cells?

    Is there a way of hiding just the cells you highlight rather than hiding the whole row/column?

    As you can see with my soccer spreadsheet, I'd like to be able to have it so whenever the user clicks on one of the 'Show/Hide' buttons at the bottom, it hides the respective home or away table. Currently, I can only seem to hide the whole columns belonging to the home or away sections.

    Also, what code do I use to make the home/away section reappear? I used a recorded macro to hide it but how can I use the same button to hide it? This is what I have so far for the home section:

    [vba]Sub showorhidehometable()
    ' hidehometable Macro
    Columns("F:M").Select
    Range("F2").Activate
    Selection.EntireColumn.Hidden = True
    End Sub[/vba]

    There's an image below to help you understand what I'm on about:

    img80.imageshack.us/img80/81/38791923.png

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can only unhide whole columns/rows.

    You can toggle it so

    [vba]

    With Columns("B")

    .Hidden = Not .Hidden
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Dec 2010
    Posts
    4
    Location
    Quote Originally Posted by xld
    You can only unhide whole columns/rows.

    You can toggle it so

    [vba]

    With Columns("B")

    .Hidden = Not .Hidden
    End With
    [/vba]
    Thank you. Is there a way of keeping the buttons within those columns, but when the section is hidden by clicking on the button, they stay in the same place?

    Currently when the button is clicked on, the section disappears but the button does as well. The only way to resolve this it seems is to place the button outside of those columns.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Set the property of the button to not move with the cells .
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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