+ Reply to Thread
Results 1 to 3 of 3

Hide Show columns

Hybrid View

Glio Hide Show columns 12-05-2007, 05:21 AM
royUK Like this? Option... 12-05-2007, 06:04 AM
Glio RoyUK Again - Thanks so... 12-05-2007, 06:10 AM
  1. #1
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Petersfield, Hampshire, UK
    MS-Off Ver
    MS Office for Mac ver 16
    Posts
    135

    Hide Show columns

    I picked up some code from here the other day which toggles hide / show columns. My problem is that there are some columns which are hidden before further columns are hidden and then when the columns are unhidden, all of them are unhidden. When the columns are unhidden I want some to remain hidden. I have tried the following, unsuccessfully

    Private Sub CommandButton1_Click()
    
        Range("M:U,X:AH").EntireColumn.Hidden = Not Range("M:U,X:AH").EntireColumn.Hidden
        Range("Y:Y,AB:AB,AE:AE").EntireColumn.Hidden = Not Range("Y:Y,AB:AB,AE:AE").EntireColumn.Hidden
    
    End Sub
    The first line hides and shows all the columns correctly, I then want the button to hide the columns in the second line.

    Any ideas, please.
    Geoff Culbertson
    Petersfield, UK

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

    Option Explicit
    
    Private Sub CommandButton1_Click()
    
        Range("M:U,X:AH").EntireColumn.Hidden = Not Range("M:U,X:AH").EntireColumn.Hidden
        Range("Y:Y,AB:AB,AE:AE").EntireColumn.Hidden = True
    End Sub
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Petersfield, Hampshire, UK
    MS-Off Ver
    MS Office for Mac ver 16
    Posts
    135
    RoyUK

    Again - Thanks so much!

+ 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