+ Reply to Thread
Results 1 to 4 of 4

column hide/unhide macro

  1. #1
    Registered User
    Join Date
    11-10-2008
    Location
    AB
    Posts
    16

    column hide/unhide macro

    Hi, I have which I hope is a simple problem, any help would be greatly appreciated.

    I am trying to hide/unhide several columns by hitting a button. It's a pretty simple macro to do it once, but how do I get a button to hide on the first click, then unhide on the second?

    you guys are great, thanks!
    Last edited by chiz; 11-11-2008 at 02:28 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Hi Chiz, and welcome to the forum.

    How about not hiding & un-hiding based on the # of clicks, rather, based on the current state of those columns. For example:
    Please Login or Register  to view this content.
    This code sets the value of the Hidden property to its opposite. So if columns A:C are hidden, this code will unhide them; and if they are visible, the code will hide them.

    This could be made a little more "basic" by using IF/THEN/ELSE statements, but the Hidden property of a range already returns a TRUE or FALSE value, so it's not needed here.

  3. #3
    Registered User
    Join Date
    11-10-2008
    Location
    AB
    Posts
    16
    Oh that is beautiful, thank-you!

    Now to push my luck... is there a way to have to change the button text based on the state of the columns?

    Specifically, have the macro button display a [+] when the columns are hidden and a [-] when they are visible?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this


    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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